Any .NET implementation of Concise Binary Object Representation(CBOR)?
Asked Answered
F

4

7

I'm on the look-out for any implementations of this new binary data representation.

Ferryman answered 5/12, 2013 at 10:58 Comment(2)
Google search for "cbor implementation c#" provides this lucky hit :-)Ducks
New C# implementation: github.com/dahomey-technologies/Dahomey.CborTonita
V
10

You can try the .Net 5.0 Extension provided by MS

  <PropertyGroup>
    <TargetFramework>net5.0</TargetFramework>
  </PropertyGroup>

https://www.nuget.org/packages/System.Formats.Cbor/5.0.0

https://learn.microsoft.com/en-us/dotnet/api/system.formats.cbor

https://github.com/dotnet/performance/search?q=cbor

Here you have an sample to write and read:

using System;
using System.Formats.Cbor;

var writer = new CborWriter();
        
writer.WriteStartArray(3);
writer.WriteInt64(DateTimeOffset.UtcNow.ToUnixTimeMilliseconds());
writer.WriteInt32(1);
writer.WriteStartArray(1);
writer.WriteInt32(9);
writer.WriteEndArray();
writer.WriteEndArray();
        
var myByteArray = writer.Encode();
    
    
var reader = new CborReader(data);
    
reader.ReadStartArray();
long unixDT = reader.ReadInt64();
int myInt = reader.ReadInt32();
reader.ReadStartArray();
int myInt2 = reader.ReadInt32();
reader.ReadEndArray();
reader.ReadEndArray();
    
var response = new object[]
    {
        unixDT,
        myInt,
        new object[] { myInt2 }
    };

Cheers

Vidicon answered 25/11, 2020 at 19:10 Comment(0)
B
4

A list of several CBOR implementations can be found at http://cbor.io — this includes a C# implementation.

Broadcloth answered 8/2, 2014 at 20:3 Comment(0)
G
2

Dahomey.Cbor

High-performance CBOR serialization framework for .Net

Features

  • Serialization/Deserialization from/to Streams, byte buffer
  • Object Model
  • Mapping to any .Net class
  • Extensible Polymorphism support based on discriminator conventions
  • Extensible Naming conventions
  • Custom converters for not supported types
  • .Net standard 2.0 support

https://github.com/dahomey-technologies/Dahomey.Cbor

Gallnut answered 30/6, 2019 at 8:15 Comment(0)
I
2

As an alternitive you can look at the Nuget-Package

PeterO.Cbor (source: https://github.com/peteroupc/CBOR).

looks (at the moment of writing) maintained and has a lot stars.

Institution answered 13/10, 2020 at 18:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.