I am building JSon object and I need to output binary data. As I understand I should create JSon string property and put encoded binary data in it? What binary encoding should be used?
3 Answers
If you want to store binary data inside the JSON object have a look at this question Binary Data in JSON String. Something better than Base64
If you want to transmit your JSON object in binary form you can simply serialize your JSON object into binary stream. Read MSDN article on (de)serialization
If you are looking for binary JSON format check http://bsonspec.org/
Further to what aku mentioned, Json.Net has support for Bson, have a look in the Newtonsoft.Json.Bson Namespace section of their documentation to find out more about the BsonReader and BsonWriter classes. They might give you what you need.

- 15,701
- 14
- 61
- 104
-
I will provide public service and if I will use 3rd party method to encode binaries then not all service users may have possibility to decode data. – Tomas Sep 05 '11 at 12:44
There is also native binary json. The format is very simple and well defined, however there is lack of open-source implementation at the moment...

- 635
- 3
- 15