1

I want deserialized part data using fastJSON fail.

class A {
    public String a;
}

The data

{"a": "a",
 "b": "b"
}

Use

A objectA = JSON.parseObject(data, A.class) 

get objectA, but the field of a is null.

If I fill the class to

class A {
    public String a;
    public String b;
}

it deserialized Ok.

Pitty
  • 329
  • 4
  • 15
  • 1
    What's your version of fastjson? There's a default feature called `com.alibaba.fastjson.parser.Feature.IgnoreNotMatch` since 1.1.2. – Anderson Jun 24 '16 at 03:05

2 Answers2

0

A.a ?

Are you sure you did A objectA = JSON.parseObject(data, A.class)

And got objectA.a ?

Otherwise your code should work ...

Jon
  • 32
  • 2
  • Yes, if I fill the class to class A { public String a; public String b;} parse correct. – Pitty Jun 24 '16 at 01:32
0

Both should work. Maybe you should update you fastjson to the latest version.

Robyn Liu
  • 241
  • 2
  • 6
  • Welcome to StackOverflow and thanks for your help. You might want to make your answer even better by adding some explanation. – Kenzo_Gilead Aug 28 '17 at 15:32