I'm having some trouble deserializing with JSON.Net in a particular scenario.
I make a request to the server and serialize an object with JSON.Net that contains a collection. I then need to add an object to that collection in my web app, but I round trip to the server to get an initialized object to insert into my collection client side. I then insert into my collection and try to save, but I get an error as newly initialized object has the same $id as something else already in the collection.
So my JSON being received by the server is in this general shape:
{
"$id": 1,
name: "random",
myArr: [
{"$id": 2, blah: "something"},
{"$id": 1, blah: "This is the item inserted into the collection on the client.
This is the one causing the deserialization error.
Note that the $id is the same as another $id already in this object graph"},
]
}
}
Do I have to manually manage the $id's myself to avoid this, or is there something baked into JSON.net to get around this?