I'm kinda getting frustrated after searching and trying around everything my mind came up with...
I try to parse a JSON file into a list or array of MyObject. I found this post Link and played around with the code. But now I always get the same Exception, whatever I do/change in the JSON file.
Exception I get:
SyntaxError: JSON.parse: unexpected non-digit at line 1 column 2 of the JSON data
What I tried:
I reduced the file to just 2 objects not containing some special stuff to make sure it works. It doesnt..
- Validating the json file with an online tool
- All different types of importing the JSON as object list/array from 1
- playing around with the JSON file
Heres the current code for importing
List<MyClass> myObjects = Arrays.asList(mapper.readValue(content, MyClass[].class));
JSON
[
{
"name":"1000.1000",
"maskId":"1000",
"fieldId":"1000",
"i18nKey":"debugLabel_1",
"label":"Logo",
"tooltip":" ---"
},
{
"name":"1000.1000",
"maskId":"1000",
"fieldId":"1000",
"i18nKey":"debugLabel_1",
"label":"Logo",
"tooltip":" ---"
}
]
MyClass
public class MyClass{
String name;
String maskId;
String fieldId;
String i18nKey;
String label;
String tooltip;
public MyClass(String name, String maskId, String fieldId, String i18nKey, String tooltip, String label) {
this.name = name;
this.maskId = maskId;
this.fieldId = fieldId;
this.i18nKey = i18nKey;
this.tooltip = tooltip;
this.label = label;
}
// Getter + Setter
}
Thanks for advices in advance.