Is the $id token a JSON Standard?

前端 未结 1 684
庸人自扰
庸人自扰 2021-01-22 11:09

Using Microsoft WebApi 2 (which uses the third party Json.NET library), let\'s say I return the following people array:

var p1 = new Person(\"Alice\         


        
相关标签:
1条回答
  • 2021-01-22 11:55

    No, $id and $ref is not part of the JSON standard (you'll notice it is not mentioned anywhere on JSON.org); it is a convention used by Json.Net to tag objects and refer to them for purposes of preserving the references on deserialization. Other JSON libraries may or may not follow the same convention. See Preserving Object References in the Json.Net documentation for more information.

    NB: There are javascript methods that can handle resolving the $id/$ref notation from Json.Net. You may be interested in these examples:

    • Resolve circular references from JSON object
    • How to restore circular references (e.g. "$id") from Json.NET-serialized JSON?
    0 讨论(0)
提交回复
热议问题