我使用Jackson版本2.4.3将我的复杂Java对象转换为String对象,所以下面是我输出的内容.输出结果如下(Fyi - I just printed some part of output)
"{\"FirstName\":\"John \",\"LastName\":cena,\"salary\":7500,\"skills\":[\"java\",\"python\"]}";
这是我的代码(PaymentTnx是复杂的Java对象)
ObjectMapper mapper = new ObjectMapper(); mapper.setVisibility(PropertyAccessor.FIELD, Visibility.ANY); String lpTransactionJSON = mapper.writeValueAsString(paymentTxn);
我不想在我的JSON字符串中看到\ slashesh.我需要做什么 ?如下所示:
"{"FirstName":"John ","LastName":cena,"salary":7500,"skills":["java","python"]}";
小智.. 11
String test = "{\"FirstName\":\"John \",\"LastName\":cena,\"salary\":7500,\"skills\":[\"java\",\"python\"]}"; System.out.println(StringEscapeUtils.unescapeJava(test));
这可能对你有帮助.
String test = "{\"FirstName\":\"John \",\"LastName\":cena,\"salary\":7500,\"skills\":[\"java\",\"python\"]}"; System.out.println(StringEscapeUtils.unescapeJava(test));
这可能对你有帮助.