1

I have a field on an object that is JSON. I can save this as a String but then when I use Jackson to serialize it and send it up to my server, the JSON is treated as a string and escaped. I'd like to send it up as actual JSON. I've made my getters and setters on the model use JSONObject even though the field is a String, and this makes ORMLite happy but now I'm getting errors when using Jackson for serialization. How can I store JSON via ORMLite and send it unescaped via Jackson (on Android)?

4

2 回答 2

0

如果它已经存储为 JSON 编码的字符串,你不想使用像杰克逊这样的库——只需按原样编写字符串。除非您确实需要以某种方式修改数据,在这种情况下,您需要先解析,然后修改,然后生成为 JSON。

于 2012-10-08T23:21:24.340 回答
0

将字符串转换为 byte[] 并保存为 byte[]。当您将其拉出时,只需将new String(bytes)其传递给杰克逊。

于 2012-10-08T23:21:40.837 回答