Search code examples
c#asp.net.netjsonwindows-phone-8

How to set a parameter in json when json is string format


How to set a parameter in json this json is string type, I have using a c# code.

Here is my json;

double Latitude = e.current.Latitude;
double Longitude = e.current.Longitude;
string json = "{ \"device_id\" : \"nishant\",\"position\" : \"47.64325,-122.14196\" }";

How to set Latitude and Longitude in position 47.64325 and -122.14196


Solution

  • You can use placeholder

    double Latitude = 47.64325;
    double Longitude = -122.14196;
    string json = "{" + "\"" + "device_id" + "\"" + ":" + "\"" + "nishant" + "\"" + "," + "\"" + "position" + "\"" + ":" + " \"" + Latitude
                    + "," + Longitude + "\"" + " }";