Monday, March 31, 2014

Create Json string Format to POST Json data to the Service


Task:Register
{
    "Device":
    {
        "DeviceId":"test-iSWzc6l8hEtvxSaaYEPVWlajSgClaPG/ug1xV5dftfQ=",
        "Operator":"Operator",
        "DeviceName":"XDeviceEmulator",
        "DeviceTotalMemory":1023,
        "ScreenWidth":480.0,
        "ScreenHeight":800.0,
        "OperatingSystem":"Android"
    },
    "Receiver":
    {
        "CountryCode":91,"Mobile":"9725910991"
    }
}
JSONObject json1 = new JSONObject();
JSONObject jsonDevice = new JSONObject();
    jsonObj.put("DeviceId", value);
    jsonObj.put("Operator", value);
    jsonObj.put("DeviceName", value);
    jsonObj.put("DeviceTotalMemory", value);
    jsonObj.put("ScreenWidth", value);
    jsonObj.put("ScreenHeight", value);
    jsonObj.put("OperatingSystem", value);
json1.put("Device", jsonDevice);
JSONObject jsonReceiver = new JSONObject();
    jsonObj.put("CountryCode", value);
    jsonObj.put("Mobile", value);
json1.put("Receiver", jsonReceiver);

Strint s1="Task:Register"+json1.toString()+"<EOF>";
Toast.makeText(getBaseContext(), "Json Strint => "+ s1 ,Toast.LENGTH_SHORT).show();