将字符串值设置为对象键-值

时间:2018-08-09 10:45:31

标签: java json

在值键对象中设置值

值字符串对象:

"{\"List\":\"
[[\\\"000000001\\\",12,0,0,3518,3520,11180,10000,3520,-4.68,-173,3537,0,-156,0,0,\\\"0\\\",3669,3510,3669,2948113,\\\"\\\\/Date(1533715176000)\\\\/\\\",3693,\\\"N1\\\",8,\\\"13\\\",\\\"NAME\\\",3509,3877],
[\\\"000000002\\\",13,0,0,970000,1010000,10000,9990,1000000,0,-1,1000000,0,-1,2759,1,\\\"2759000000\\\",1000000,1000000,1000000,1,\\\"\\\\/Date(1533714918000)\\\\/\\\",1000001,\\\"N4\\\",8,\\\"45\\\",\\\"NAME\\\",950001,1050001], ...

设置为此类:

Number.Class
private String id;
private String wordNumber
, ....

转换字段的示例:

setId = 000000001  - setId = 000000002

setWordNumber = 12 - setwordNumber = 13

我这样做了:

String json = " "{\"List\":\"
[[\\\"000000001\\\",12,0,0,3518,3520,11180,10000,3520,-4.68,-173,3537,0,-156,0,0,\\\"0\\\",3669,3510,3669,2948113,\\\"\\\\/Date(1533715176000)\\\\/\\\",3693,\\\"N1\\\",8,\\\"13\\\",\\\"NAME\\\",3509,3877],";
    Map<String, Object> map = mapper.readValue(json, new TypeReference<Map<String,Object>>(){});

但不幸的是,它不是:(

有人可以指导我, 请

1 个答案:

答案 0 :(得分:-1)

我假设您想将JSON解析为Java对象?

有各种各样的库可以做到这一点,例如Gson

有了Gson,您可以做到:

YourClass object = new Gson().fromJson(json, YourClass.class);

如果这不是您要实现的目标,请阐明问题。