c# - NewtonSoft PreserveReferenceHandling: $id property standards, override value generation -
if object being serialized marked [jsonobject(isreference = true)]
serialized $id
property, consist of incremented integer value each distinct object reference in graph of objects being serialized.
but if objects serialized independently, joined together, , deserialized (aka: chatty get, chunky post/put), these values need re-keyed, or errors thrown on deserialization , resulting graph incomplete 'duplicate' references ignored.
in cases though, objects have own unique ids (ie: guids).
i've worked around in 2 ways:
- turn off reference preservation, ,
- add dummy property object merely exposes native id, , decorating
[jsonproperty("$id")]
and while don't care reference counting, may in future, don't having duplicate properties in resulting json same guid value.
so i'm wondering if there way force newtonsoft use id
property on object in place of $id
property?
[ alternatively, mark object's id property [jsonproperty("$id")]
, change json-consuming code use $id
property instead of id
.. don't idea.. however, if $ref
, $id
json standards (are they?) , client frameworks not gracefully try use id
in place of absent $id
(should care?), option duplicate properties or forcing consuming code use $id
. ]
if can't (or shouldn't) change property used reference tracking, there reasons why forcing guid $id
property equally bad form? (ie: if there reasonable standard this, dictate numeric-only data value?)
thanks
Comments
Post a Comment