JSONObject zawiera znaki ucieczki

Buduję symulator do publikowania danych JSON w uruchomionej usłudze.

JSON powinien wyglądać tak:

{"sensor":
       {"id":"SENSOR1","name":"SENSOR","type":"Temperature","value":100.12,"lastDateValue":"\/Date(1382459367723)\/"}
}

Próbowałem tego z „zaawansowanym klientem REST” w Chrome i to działa dobrze. Data jest poprawnie analizowana przez usługę Web ServiceStack.

Chodzi więc o napisanie symulatora czujnika, który wysyła takie dane do usługi internetowej.

Stworzyłem to w Javie, więc mogłem uruchomić go na moim raspberry pi.

To jest kod:

    public static void main(String[] args) {

    String url = "http://localhost:63003/api/sensors";
    String sensorname = "Simulated sensor";
    int currentTemp = 10;
    String dateString = "\\" + "/Date(" + System.currentTimeMillis() + ")\\" + "/";
    System.out.println(dateString);

    System.out.println("I'm going to post some data to: " + url);

    //Creating the JSON Object
    JSONObject data = new JSONObject();
    data.put("id", sensorname);
    data.put("name", sensorname);
    data.put("type", "Temperature");
    data.put("value", currentTemp);
    data.put("lastDateValue", dateString);
    JSONObject sensor = new JSONObject().put("sensor",  data);

    //Print out the data to be sent
    StringWriter out = new StringWriter();
    sensor.write(out);

    String jsonText = out.toString();
    System.out.print(jsonText);

    //Sending the object
    HttpClient c = new DefaultHttpClient();
    HttpPost p = new HttpPost(url);
    p.setEntity(new StringEntity(sensor.toString(), ContentType.create("application/json")));

    try {
        HttpResponse r = c.execute(p);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

Wynik tego programu jest następujący:

\/Date(1382459367723)\/
I'm going to post some data to: http://localhost:63003/api/sensors
{"sensor":{"lastDateValue":"\\/Date(1382459367723)\\/","id":"Simulated sensor","name":"Simulated sensor","value":10,"type":"Temperature"}}

Problem polega na tym, że ciąg JSONObject nadal zawiera te znaki ucieczki. Ale kiedy drukuję ciąg na początku, nie zawiera on znaków ucieczki. Czy jest jakiś sposób, aby się ich pozbyć? Moja usługa nie może ich przeanalizować ...

To jest przykład tego, co wysyłam z resztą klienta w Chrome:

 {"sensor":{"id":"I too, am a sensor!","name":"Willy","type":"Temperature","value":100.12,"lastDateValue":"\/Date(1382459367723)\/"}}

questionAnswers(2)

yourAnswerToTheQuestion