Saturday, 15 January 2011

c# - Setting ref to children values in JSON.NET -



c# - Setting ref to children values in JSON.NET -

i have problem related json.net. have project on side , project has been converted entity framework json values (all selects , queries written).

because of circular reference problems, using json.net. however, when code beingness generated json, first kid of element gets $id value first , parent gets $ref value.

this tackling issue me , know can write own anonymous queries avoid problem. because of size of project, late alter queries, because old programmer has written project is.

i wondering if there way set alternative in json.net.

let me explain problem in way:

let's have json coming json.net:

1-question $id:1 1-a- response_group $id:2 **1-a-a-response $id: 3** **1-response $ref:3**

if want alter behavior want this:

1-question $id:1 1-a- response_group $id:2 **1-a-a-response $ref:3** **1-response $id:3**

the upper branch dominates lower branch.

is there way accomplish on json.net side? if there isn't alternative in json.net, should fork json.net project , start changing logic in way?

if there isn't way solve start writing anonymous queries.

there not alternative alter way works in json.net. reason works way because json.net uses forward-only reader when deserializing json, particular $id must come before corresponding $ref values. otherwise cannot resolve references.

to create work way suggesting, either need create 2 passes on json (which may not possible, e.g. network streams) or generate proxy objects stand in unresolved references (which harder sounds).

no 1 stopping forking project if think want tackle this, think best bet seek work functionality json.net offers if @ possible.

c# json.net

No comments:

Post a Comment