Closed yangxiaoweihn closed 2 years ago
sdk: ">=2.15.1 <3.0.0" path: ^1.8.1 dart-json-mapper: 2.2.1+3
code:
/// entity @jsonSerializable class Category { @JsonProperty(name: ['id', 'id_a', 'id_b', 'id_test'],) int id = 0; String uuid = ''; }
/// test List<String> test = [ '''{"id": 90, "name": "id"}''', '''{"id_a": 91, "name": "id_a"}''', '''{"id_test": 92, "name": "id_test"}''', '''{"id_b": 93, "name": "id_b"}''', ]; for (var element in test) { Log.log(">>>>> ${JsonMapper.deserialize<Category>(element).toString()}"); Log.log("\n"); }
/// compiled reflectable
/// out put
id
id_test
id_a
id_b
Thank you so much, delivered in 2.2.2 🎉
2.2.2
tested result: Jsonproperty annotation only support the primary name and the last aliases, other aliases ignored.
code:
/// compiled reflectable
/// out put
so, Jsonproperty annotation only support the first
id
and the lastid_test
,id_a
andid_b
in the middle are ignored