JSON转换为Java对象

时间:2012-08-09 18:17:09

标签: java json jackson

我试图将以下字符串从Python解析为Java Object,但我为其创建的Java对象将属性显示为null我可以看到它的id部分而不是其他财产。

请在下面找到Java类:

public String getId()
{
    return id;
}

public void setId(String id)
{
    this.id = id;
}
@JsonProperty("remote-system-desc")
public String getRemote_system_desc()
{
    return remote_system_desc;
}

@JsonProperty("remote-system-desc")
public void setRemote_system_desc(String remote_system_desc)
{
    this.remote_system_desc = remote_system_desc;
}
@JsonProperty("remote-system-capabilities")
public String getRemote_system_capabilities()
{
    return remote_system_capabilities;
}

@JsonProperty("remote-system-capabilities")
public void setRemote_system_capabilities(String remote_system_capabilities)
{
    this.remote_system_capabilities = remote_system_capabilities;
}

@JsonProperty("remote-chassis-id")
public String getRemote_chassis_id()
{
    return remote_chassis_id;
}

@JsonProperty("remote-chassis-id")
public void setRemote_chassis_id(String remote_chassis_id)
{
    this.remote_chassis_id = remote_chassis_id;
}

public List<ExternalSwitchPort> getPorts()
{
    return ports;
}

public void setPorts(List<ExternalSwitchPort> ports)
{
    this.ports = ports;
}
@JsonProperty("remote-system-name")
public String getRemote_system_name()
{
    return remote_system_name;
}

@JsonProperty("remote-system-name")
public void setRemote_system_name(String remote_system_name)
{
    this.remote_system_name = remote_system_name;
}
  

“externalSwitches”:[{“id”:“00:15:60:00:eb:80”,“remote-system-desc”:“ProCurve J4904A Switch 2848,修订版I.10.77,ROM I.08.07 (/ sw / code / build / mako(mkfs))“,”remote-system-capabilities“:”bridge,router“,”remote-chassis-id“:”00:15:60:00:eb:80“ ,“ports”:[{“remote-port-desc”:“33”,“id”:“enc0:iobay2:X5”,“remote-port-id”:“33”}],“remote-system-名称“:”VirtSW Rack9“},{”id“:”00:13:21:dd:35:00“,”remote-system-desc“:”ProCurve J4904A Switch 2848,修订版I.10.77,ROM I. 08.07(/ sw / code / build / mako(mkfs))“,”remote-system-capabilities“:”bridge,router“,”remote-chassis-id“:”00:13:21:dd:35:00 “,”ports“:[{”remote-port-desc“:”19“,”id“:”enc0:iobay1:X5“,”remote-port-id“:”19“}],”remote-system -name“:”swr5-hpqcorp“}]}

我无法确定是由于数据内容还是因为它无法正确解析属性remote-system-desc,但我在JSON属性中提到过。

0 个答案:

没有答案