.net - Exception when trying to deserialize the JSON object -
i trying deserialiaze json object on line ser.writeobject(ms, inpjsonobj);
exception thrown
edit: suggested created new memory stream , copied modified object in new stream . "out" string still blank !
datacontractjsonserializer ser = new datacontractjsonserializer(typeof(testjson)); memorystream ms = new memorystream(encoding.unicode.getbytes(inpstr)); ms.position = 0; testjson obj = (testjson)ser.readobject(ms); obj.var11 = 99; obj.var21 = 199; memorystream ms1 = new memorystream(); ser.writeobject(ms1, obj); ms1.position = 0; streamreader sr = new streamreader(ms1); out = sr.readtoend(); ms1.close(); ms.close();
without knowing exception details can guess, looks problem creating instance of non-resizable memory stream , trying write updated object - result of serialization larger original string , stream cannot accept it.
Comments
Post a Comment