Reputation: 33
I want to parse a JSON like this one:
{
"Header":{"S":"1A-01-07"},
"Items":{"L":[{"M":{"Name":{"S":"SL-1A Pre-Action (Green)"},"Roles":{"L":[{"S":"3cc3"}]}}},
{"M":{"Name":{"S":"SL-8A Pre-Action (Yellow)"},"Roles":{"L":[{"S":"3cc3"}]}}}]
}
}
and for that I created this class structure:
public class CLI {
Header Header;
Items Items;
public Header getHeader() {
return Header;
}
public void setHeader(Header h) {
Header = h;
}
public Items getItems() {
return items;
}
public void setItems(Items i) {
items = i;
}
}
class Header {
String S;
public String getS() {
return S;
}
public void setS(String s) {
S = s;
}
}
class Items {
List<Map<Roles,Name>> L;
public List<Map<Roles, Name>> getL() {
return L;
}
public void setL(List<Map<Roles, Name>> l) {
L = l;
}
}
class Roles {
List<Item1> itemList;
public List<Item1> getLista() {
return itemList;
}
public void setLista(List<Item1> l) {
this.itemList = l;
}
}
class Name {
Item1 name;
public Item1 getName() {
return name;
}
public void setName(Item1 n) {
this.name = n;
}
}
class Item1 {
String S;
public String getS() {
return S;
}
public void setS(String s) {
S = s;
}
}
but when I try to deserialize it with fromJson("myJSON", CLI.class) I get this error: "Unterminated object at line 1 column 80 path $.Items.[0]...". I've checked the structure a hundred times, but I don't see what could be wrong with it.
Could you help me find what the problem?
Upvotes: 0
Views: 231
Reputation: 34
Your json is incorrectly formatted, see http://www.w3schools.com/json/ for some examples but essentially no =
Try and google a json parser that will show the errors or use an addon for text editors such as Atom e.g. https://atom.io/packages/atom-beautify Which will auto format your json and show errors
Upvotes: 1