我米用傑克遜庫從JSON來反序列化。我需要從這個json中只提取2個值,即c1和d1。我已經使用這個代碼...我需要知道克服獲得C1和D1值正確的方法...如何從一個嵌套的JSON字符串值2與傑克遜
我的JSON
{"Alpha":{"A":{"B":{"C":{"c1":1234,c2:"abcd"},"D":{"d1":"xyz","d2":5678,"d3":"qwerty"},"E":[{"e1":456,"e2":"mnop"},{"e1":098,"e2":"qrst"}]}}},"X"{"x1":8098}}
ObjectMapper mapper = new ObjectMapper();
mainclass alphaobj = mapper.readValue(new File("C:\\employee.json"), mainclass.class);
System.out.println(alphaobj.A.B.C.getc1());
你怎麼說「克服獲得C1和D1值」是什麼意思?也請顯示你的'mainclass'定義。 – 2012-08-17 14:33:23