This project has moved. For the latest updates, please go here.

Updating objects

Aug 24, 2009 at 10:18 AM


before anything I thank James Newton-King because of excellent JSON library.

I have a problem that I think it solved by JSON API but there is no way to use these API to solve mine.

Please note these dump semi-codes :

Server :

Class1 obj1 = new Class1( ... );

Session["obj1"]= obj1;

Send_To_Client( JSONConvert.Serialize(obj1) );

Client :

// Update Obj1

Post_To_Server( JSON.Serialize(obj1) );

Server :

Class1 obj1 = Session["obj1"];

In this situation I want update obj1 but I can't !!! by James JSON API i only can create new Object and I cant update source object !!!

Can anybody help me ?

Aug 24, 2009 at 8:35 PM
Edited Aug 24, 2009 at 8:36 PM

Couldn't you do something like the following?  This assumes that the Session["obj1"] data is a json string... but it looks like this might not be the case above... but you are getting json data back somewhere, so whatever that string is just place it in the following code.


obj1 = JsonConvert.DeserializeObject<Class1>(Session["obj1"]);


Aug 29, 2009 at 6:27 AM

tank you Mr/Mrs lordicarus

but these is not my problem, i have no problem in holding or transmitting json string. I cant update an existing object by submitted json string. Please help me ...

Sep 1, 2009 at 9:36 PM

Have you tried Populate on JsonSerializer?

Sep 3, 2009 at 5:36 AM

tank you JamesNK.