简体   繁体   English

未被识别的字段,未标记为可忽略

[英]unrecognized field, not marked as ignorable

I get an error while trying to fill fields of a list of objects using ObjectMapper 尝试使用ObjectMapper填充对象列表的字段时出错

public class FormMap {
    private String id;
    private String strengthRouteFormId;
    private String fdaid;
    private String formName;
    private String formDescription;
    private String ncitQuantityUnitTermId;
    private String ncitStrengthFormTermId;
    private String ncitId;
    private String ncitSubsetCode;
    private String ncpdpSubsetPreferredTerm;
    private String ncitCode;
    private String ncpdpPreferredTerm;
    private String ncitPreferredTerm;
    private String ncitDefinition;
    private StrengthRouteForm strengthRouteForm;
}

public class StrengthRouteForm {
    private String id;
    private String medicationId;
    private String strength;
    private String routeName;
    private String gsForm;
    private String alternativeFormName;
    private String clinicalDoseFormName;
    private String normalizedFormName;
    private String topLevelDoseFormName;
    private List<FormMap> formMaps;
}

I have this 2 classes and I want to create a List of StrengthRouteForm using ObjectMapper and a Json 我有这两个类,我想使用ObjectMapper和一个Json创建一个StrengthRouteForm列表

ObjectMapper objectMapper = new ObjectMapper();   
objectMapper.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true);
List<StrengthRouteForm> strengthRouteForms = null;
strengthRouteForms = Arrays.asList(objectMapper.readValue("string json", StrengthRouteForm[].class));

and i get this error: 我收到此错误:

Unrecognized field "FormMap" (class com.cgm.us.ais.core.model.StrengthRouteForm), not marked as ignorable

JSON may look like this: JSON可能如下所示:

"StrengthRouteForm": [
                {
                    "Strength": "0.25",
                    "RouteName": "Oral",
                    "GSForm": "Oral tablet",
                    "AlternativeFormName": "Oral Solid",
                    "ClinicalDoseFormName": "Oral tablet",
                    "NormalizedFormName": "Oral tablet",
                    "TopLevelDoseFormName": "Oral preparations - solid forms",
                    "FormMap": [
                        {
                            "FDAID": "500",
                            "FormName": "Tab",
                            "FormDescription": "Tablet",
                            "NCItQuantityUnitTermID": "106",
                            "NCItStrengthFormTermID": "447",
                            "NCItId": "106",
                            "NCItSubsetCode": "C89510",
                            "NCPDPSubsetPreferredTerm": "NCPDP QuantityUnitOfMeasure Terminology",
                            "NCItCode": "C48542",
                            "NCPDPPreferredTerm": "Tablet",
                            "NCItPreferredTerm": "Tablet Dosing Unit",
                            "NCItDefinition": "A dosing unit equal to the amount of active ingredient(s) contained in a tablet."
                        },
                        {
                            "FDAID": "500",
                            "FormName": "Tab",
                            "FormDescription": "Tablet",
                            "NCItQuantityUnitTermID": "106",
                            "NCItStrengthFormTermID": "447",
                            "NCItId": "447",
                            "NCItSubsetCode": "C89508",
                            "NCPDPSubsetPreferredTerm": "NCPDP StrengthForm Terminology",
                            "NCItCode": "C42998",
                            "NCPDPPreferredTerm": "Tablet",
                            "NCItPreferredTerm": "Tablet Dosage Form",
                            "NCItDefinition": "A solid composed of a mixture of that active and/or inert ingredient(s) are pressed or compacted together, usually in the form of a relatively flat and round, square or oval shape."
                        }
                    ]
                }
            ]

My question is: how can I make this list: formMaps to map FormMap from JSON 我的问题是:如何才能让这个列表:formMaps从JSON映射FormMap

To enable changing the name of the target Java field for a given JSON property, the annotation @JsonProperty can be used. 要为给定的JSON属性更改目标Java字段的名称,可以使用注释@JsonProperty In your case, instead of being forced to rename private List<FormMap> formMaps to formMap , the annotation 在您的情况下,而不是强制将private List<FormMap> formMaps重命名为formMap ,注释

@JsonProperty("FormMap")
private List<FormMap> formMaps;

can be used. 可以使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法识别的字段类未标记为可忽略 - Unrecognized field class not marked as ignorable JSON 到 Java 对象 - 无法识别的字段,未标记为可忽略 - JSON to Java object - Unrecognized field, not marked as ignorable Spring Jackson-无法识别的字段“ response”在以下位置未标记为可忽略 - Spring Jackson - Unrecognized field \“response\” not marked as ignorable at Jackson Json 反序列化:无法识别的字段“...”,未标记为可忽略 - Jackson Json Deserialisation: Unrecognized field “…” , not marked as ignorable Jackson 与 JSON:无法识别的字段,未标记为可忽略 - Jackson with JSON: Unrecognized field, not marked as ignorable jackson java无法识别的字段未标记为可忽略 - jackson java Unrecognized field not marked as ignorable JSON:无法识别的字段“值”( <objectClass> ),没有标记为可忽略的 - JSON : Unrecognized field “value” (<objectClass>), not marked as ignorable 将 JSON 映射到 POJO 进行处理 - 无法识别的字段未标记为可忽略 - Map JSON to POJO For Processing - Unrecognized field not marked as ignorable 无法保存用户:无法识别的字段类未标记为可忽略 - Unable to save users: Unrecognized field class not marked as ignorable 解析json字符串时,无法识别的字段(未标记为可忽略) - Unrecognized field , not marked as ignorable ,when parsing json string
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM