You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Example is below, this gist of it is that when serializing a class the '}' is missing, which causes incorrect json and issues when later deserializing.
` @test
public void testClassSerialization(){
String json = Boon.toJson(new MyModel(new KeyValueFinderImpl(), 100));
puts(json);
// Missing the '}' after 'KeyValueFinderImpl"'
//{"keyValueFinder":{"class":"org.boon.json.JsonParserAndMapperBaseTest$KeyValueFinderImpl","size":100}
MyModel myModel = Boon.fromJson(json, MyModel.class);
puts(myModel.getSize()); // returns 0, should be 100
// manually placing the }
String correctJson = "{\"keyValueFinder\":{\"class\":\"org.boon.json.JsonParserAndMapperBaseTest$KeyValueFinderImpl\"},\"size\":100}";
myModel = Boon.fromJson(correctJson, MyModel.class);
puts(myModel.getSize()); // returns 100 now
}
public static class MyModel {
private KeyValueFinder keyValueFinder;
private int size;
public MyModel() {
}
public MyModel(KeyValueFinder keyValueFinder, int size) {
this.keyValueFinder = keyValueFinder;
this.size = size;
}
public KeyValueFinder getKeyValueFinder() {
return keyValueFinder;
}
public void setKeyValueFinder(KeyValueFinder keyValueFinder) {
this.keyValueFinder = keyValueFinder;
}
public int getSize() {
return size;
}
public void setSize(int size) {
this.size = size;
}
}
public interface KeyValueFinder{
int getValue(String key);
}
public static class KeyValueFinderImpl implements KeyValueFinder{
@Override
public int getValue(String key) {
return key.hashCode();
}
}
`
The text was updated successfully, but these errors were encountered:
Example is below, this gist of it is that when serializing a class the '}' is missing, which causes incorrect json and issues when later deserializing.
`
@test
public void testClassSerialization(){
String json = Boon.toJson(new MyModel(new KeyValueFinderImpl(), 100));
puts(json);
// Missing the '}' after 'KeyValueFinderImpl"'
//{"keyValueFinder":{"class":"org.boon.json.JsonParserAndMapperBaseTest$KeyValueFinderImpl","size":100}
`
The text was updated successfully, but these errors were encountered: