Hello,
looks like that when an object get serialized/unserialized more than once, sometimes double quotes are not escaped.
Here is the code to replicate the error, i am using boon v0.30 and java 1.7.x
import java.util.HashMap;
import java.util.Map;
import org.boon.json.JsonFactory;
import org.boon.json.ObjectMapper;
public class MyObject {
private String title;
private Map<String, Object> attrs;
/**
* @return the title
*/
public String getTitle() {
return title;
}
/**
* @param title the title to set
*/
public void setTitle(String title) {
this.title = title;
}
/**
* @return the attrs
*/
public Map<String, Object> getAttrs() {
return attrs;
}
/**
* @param attrs the attrs to set
*/
public void setAttrs(Map<String, Object> attrs) {
this.attrs = attrs;
}
public static void main(String[] args) {
// create object
MyObject myobject = new MyObject();
// add a title and attributes
myobject.setTitle("title with \" double qoutes");
Map<String,Object> attributes = new HashMap<>();
attributes.put("author", "author with \" double quotes");
myobject.setAttrs(attributes);
// create ObjectMapper
ObjectMapper mapper = JsonFactory.create();
// serialize myobject to json
String myobjectJson = mapper.toJson(myobject);
System.out.println(myobjectJson);
// prints: {"title":"title with \" double qoutes","attrs":{"author":"author with \" double quotes"}}
// parse myobjectJson to an object
MyObject myobjectParsed = mapper.fromJson(myobjectJson, MyObject.class);
// serialize again my myobjectParsed to json
myobjectJson = mapper.toJson(myobjectParsed);
System.out.println(myobjectJson);
// double quoted for attrs are not escaped
// prints: {"title":"title with \" double qoutes","attrs":{"author":"author with " double quotes"}}
MyObject myobjectParsed2 = mapper.fromJson(myobjectJson,MyObject.class);
// Exception in thread "main" org.boon.json.JsonException: expecting current character to be ':' but got '}' with an int value of 125
}
}
Hello, looks like that when an object get serialized/unserialized more than once, sometimes double quotes are not escaped.
Here is the code to replicate the error, i am using boon v0.30 and java 1.7.x