c# - JavaScriptSerializer.Deserialize Gives Null Fields -



c# - JavaScriptSerializer.Deserialize Gives Null Fields -

i sent next json wcf service accepts stream parameter.

{"reservationstream": {"clientfirstname":"abe", "clientlastname":"lincoln", "clientphone":"0544944860", "clientemail":"abe@mail.com", "pickuplocationid":"3699", "pickupaddressstring":"jfk airport terminal 1", "pickupflightnumber":"ly001", "pickupairline":"el al", "pickupairportname":"john f kennedy intl", } }

in debugger, stream variable shows values expected. want deserialize class defined follows:

public class reservationstream { public string clientfirstname { get; set; } public string clientlastname { get; set; } public string clientphone { get; set; } public string clientemail { get; set; } public string pickuplocationid { get; set; } public string pickupaddressstring { get; set; } public string pickupflightnumber { get; set; } public string pickupairline { get; set; } public string pickupairportname { get; set; } }

when phone call

javascriptserializer javascriptserializer = new javascriptserializer(); reservationstream structuredreservations = javascriptserializer.deserialize<reservationstream>(strjson);

no exception thrown, of fields have null values. mistake?

i think it's because json object nested within reservationstream tag.

try just:

{ "clientfirstname":"abe", "clientlastname":"lincoln", "clientphone":"0544944860", "clientemail":"abe@mail.com", "pickuplocationid":"3699", "pickupaddressstring":"jfk airport terminal 1", "pickupflightnumber":"ly001", "pickupairline":"el al", "pickupairportname":"john f kennedy intl" }

c# json wcf

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -