Я пытаюсь проанализировать JSON для объекта в Java, JSON что-то вроде этого
{"usage":{"text_characters":22,"features":1,"text_units":1},"entities":[{"count":1,"text":"pisos","disambiguation":{"subtype":["NONE"]},"type":"Producto"},{"count":1,"text":"No hay","disambiguation":{"subtype":["NONE"]},"type":"Quiebre_Stock"},{"count":1,"text":"madera","disambiguation":{"subtype":["NONE"]},"type":"Producto"}],"language":"es"}
Я пытаюсь сопоставить с этим методом
parsedJsonObj = mapper.readValue(result, NLUEntitiesRelations.class);
и NLUEntitiesRelations.class
такие
public class NLUEntitiesRelations {
private UsageNLU usage;
private List<EntityNLU> entities;
private String language;
//getter and setter
}
public class UsageNLU {
private int text_characters;
private int features;
private int text_units;
//getersand setter
}
public class EntityNLU {
private int count;
private String text;
private DisambiguationNLU disambiguation;
private String type;
//getter and setter
}
public class DisambiguationNLU {
private List<String> subtype;
//getter and setter
}
но при его выполнении мне выдается следующая ошибка, и я старался создать новый класс, когда это был JSON внутри JSON, как в usagenlu
Error: com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of java.lang.String out of START_OBJECT token at [Source: { "usage": { "text_units": 1, "text_characters": 22, "features": 1 }, "language": "es", "entities": [ { "type": "Producto", "text": "pisos", "disambiguation": { "subtype": [ "NONE" ] }, "count": 1 }, { "type": "Quiebre_Stock", "text": "no hay", "disambiguation": { "subtype": [ "NONE" ] }, "count": 1 }, { "type": "Producto", "text": "madera", "disambiguation": { "subtype": [ "NONE" ] }, "count": 1 } ] } ; line: 2, column: 12] (through reference chain: cl.sodimac.watson.alchemy.json.NLUEntitiesRelations["usage"])