Hello Ahmad,
the solution to your problem is $.extend() or jQuery.extend().
I'll give you an example below, but please also go to the jQuery
website here:
jQuery.extend()[
^]
and for the JSON plugin to jQuery please read this:
jQuery-JSON Plugin[
^]
Example:
eval("var p= " + jsonStringOfMyObject + ";");
dataFromServer = p;
fullyUsableClassAWithMethodsAndAll = new ClassA();
$.extend(fullyUsableClassAObjectWithMethodsAndAll, dataFromServer);
If you return more than one type of object form the server you'll have to make sure to create the appropriate instance before the $.extend() part.
I hope you could follow me :) .
If you have any doubts, check back with me.
Regards,
Manfred