Click here to Skip to main content
15,909,466 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have the Json request in following format:
{
"hardwareId": "123-TEST-4567890",
"type":"DeviceLocation",
"request": {
"latitude": "33.75",
"longitude": "-84.39",
"elevation": "0",
"updateState": true,
"eventDate": "2016-02-10T19:40:03.390Z"
}
}

i am unable to use the setters and getters for request field. How do i set and get array values in C#. Thanks in advance

What I have tried:

I am able to set and get hardwareId and Type fieds. I am unable to do so with the request field
Posted
Updated 20-Nov-16 21:50pm
Comments
Suvendu Shekhar Giri 21-Nov-16 2:54am    
Have you missed sharing the relevant code where you are setting the properties?

This depends if you have created obj1 from the JSON, or if you are trying to create the JSON from an object you have instantiated in C#.

First case, you simply access the request members by:
C#
obj1.request.latitude = "33.75"; 
obj1.request.longitude = "-84.39" // etc

Second case:
C#
obj1.request = new () {
   latitude = "33.75",
   longitude = "-84.39",  // etc
};
 
Share this answer
 
obj1.hardwareid = "ask-TEST-2";
obj1.type = "DeviceLocation";

then how do i proceed with the request ?
 
Share this answer
 
i am trying to create the json from object
 
Share this answer
 
Comments
Karthik_Mahalingam 21-Nov-16 6:44am    
use "Reply" or "Have a Question or Comment?" button to reply, post queries, dont use solution widget

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900