You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
CBOR serialization of a given JSON value does not serialize #641
Hi,
I was CBOR serializing a JSON object, and noticed that, whereas when dumping a json object to a string, json string values (i.e., case value_t::string )are escaped (a call to escape_string is made), no such call is made when json values are string values in the CBOR approach.
I was reading the CBOR CRF 7049 and it seems that strings do not need to be escaped when serializing to CBOR.
From your library the behavior is consistent, you don't escape when serializing, nor except to be escaped when de-serializing.
But it appears that Newtonsoft.Json (C# library), expects that. Is it a valid expectation? Is it possible to have a serialization that behaves in this way, in case some libraries expect that behavior?
My use case involves reading the cbor byte string output in c#.
C++ side:
Such output string by then, is wrongly formed: {"characters": [{"name": "Clara Oswald"}, {"name": "Kensi Blye"}, {"name": "Temperance "Bones" Brennan"}]}
and cannot, obviously be parsed:
Activity
nlohmann commentedon Jun 28, 2017
I'm on holiday right now and cannot have a look at this issue for the next two weeks.
CodeMasterYi commentedon Jun 29, 2017
what about json_doc.dump()?
davidalbertonogueira commentedon Jun 29, 2017
Already fixed it. It has nothing to do with nlohmann::json.
In C#, the correct call is cbor.ToJSONString() instead of cbor.ToString(), as I was doing.