패키지, 저장소 및 앱 카테고리 검색

패키지 상세v6.5.2

cbor

Dart용 CBOR 라이브러리입니다. RFC8949 호환 인코딩/디코딩 CBOR 구현입니다.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
32.2만
좋아요
41
Pub 점수
160

패키지 설치

flutter pub add cbor

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

RFC8949을 준수하는 CBOR(간결한 바이너리 객체 표현) 데이터를 인코딩하고 디코딩하기 위한 Dart 라이브러리입니다. 구조화된 데이터를 효율적으로 작고 컴팩트한 바이너리 형식으로 시리얼라이즈할 수 있으며, 대역폭과 성능이 중요한 IoT, 모바일 및 웹 애플리케이션에 적합합니다. 이 패키지는 모든 표준 CBOR 유형을 지원하며 Dart 생태계와 원활하게 통합됩니다.

사용 사례

  • 사물인터넷 장치에서의 효율적인 데이터 직렬화
  • 모바일 앱에서의 컴팩트한 페이로드 전송
  • CBOR를 사용하는 시스템과의 상호 운용성
  • 웹 API 데이터 교환
  • 경량 형식에 이진 데이터 포함하기

주요 기능

  • RFC8949 준수
  • 모든 CBOR 데이터 유형을 지원합니다
  • 경량 바이너리 인코딩
  • 크로스 플랫폼 호환성
  • 인코딩/디코딩을 위한 간단한 API
  • 모든 주요 플랫폼에서 작동합니다

적합한 대상

  • 작은 데이터 형식이 필요한 개발자
  • 고성능 직렬화가 필요한 응용 프로그램
  • CBOR를 통해 통신하는 시스템
  • 제한된 대역폭을 가진 모바일 및 웹 앱

고려 사항

  • CBOR 형식으로만 제한
  • 스키마 검증을 위한 내장 지원 없음
  • CBOR 의미론에 대한 이해가 필요합니다
  • 인간이 읽을 수 있는 데이터에는 적합하지 않습니다

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

cbor

Build Status Pub Version

Documentation

This package provides an encoding/decoding package for the Concise Binary Object Representation as documented in RFC8949.

CBOR is increasingly used as a line protocol in the IOT world where the overhead of transmitting JSON on constrained devices can be large in packet size and processing overheads.

Features

  • Streamlined encoding and decoding of CBOR, including indefinite length and streamed decoding.
  • Set of types that semantically handles types, nesting, and tags.
  • Automatic conversion for the smallest size needed for integers.
  • Automatic conversion for the smallest precision needed for floating point numbers.
  • Any value can be the key for a map.
  • Optional simple API for encoding and decoding directly to Dart objects.
  • Pretty-printing and conversion to JSON.
  • Rational numbering encoding is supported on tag 30.

Usage

Two APIs are provided, cbor.dart and simple.dart.

cbor.dart

Encodes from CborValue and decodes to CborValue.

The CborValue contains the tags for this item, and its subtypes are used to identify the type and tags for the item. This allows one to handle information encoded in a more lossless way.

Inheritance tree for CborValue looks something like this:

CborValue
├── CborInt
│   ├── CborSmallInt
│   └── CborDateTimeInt
├── CborBytes
│   └── CborBigInt
├── CborString
│   ├── CborDateTimeString
│   ├── CborBase64
│   ├── CborBase64Url
│   ├── CborMime
│   └── CborRegex
├── CborFloat
│   └── CborDateTimeFloat
├── CborSimpleValue
│   ├── CborNull
│   ├── CborBool
│   └── CborUndefined
├── CborMap
└── CborList
    ├── CborDecimalFraction
    ├── CborRationalNumber
    └── CborBigFloat
Example
import 'package:cbor/cbor.dart';

test('{1:2,3:4}', () {
   final encoded = cbor.encode(CborMap({
      CborSmallInt(1): CborSmallInt(2),
      CborSmallInt(3): CborSmallInt(4),
   }));
   expect(encoded, [0xa2, 0x01, 0x02, 0x03, 0x04]);
});

Check out the example folder for more examples.

simple.dart

Less powerful, but may be the best option for simple applications that do not need any of the fancy features of the cbor API above.

The encoder in simple API will operate similarly to constructing a CborValue from the input and the encoding it.

Decoder will translate the input to a common Dart object, ignoring any extra tags after the type is decided.

Example
import 'package:cbor/simple.dart';

test('{1:2,3:4}', () {
   final encoded = cbor.encode({
      1: 2,
      3: 4,
   });
   expect(encoded, [0xa2, 0x01, 0x02, 0x03, 0x04]);
});
Additional RFC's implemented

The following CBOR RFC's have also been implemented in the package :-

  • RFC8746 - Concise Binary Object Representation (CBOR) Tags for Typed Arrays.

카테고리

의존성

의존성 목록 6 개

소스 저장소

이 패키지를 사용하는 프로젝트