k-paxian / dart-json-mapper

Serialize / Deserialize Dart Objects to / from JSON
https://pub.dev/packages/dart_json_mapper
Other
399 stars 33 forks source link

`JsonMapper.copyWith` doesn't respect deep merge #209

Closed k-paxian closed 1 year ago

k-paxian commented 1 year ago

Discussed in https://github.com/k-paxian/dart-json-mapper/discussions/208

Originally posted by **ozaner** December 25, 2022 ```dart @jsonSerializable class ComposableCar { @JsonProperty(name: 'leftWheel/tire/thickness') final int thicknessLeft; @JsonProperty(name: 'rightWheel/tire/thickness') final int thicknessRight; @JsonProperty(name: 'rightWheel/tire/color') final String? tireRightColor; const ComposableCar(this.thicknessLeft, this.thicknessRight, this.tireRightColor); } ``` If we run the `copyWith` method on this: ```dart var newCar = JsonMapper.copyWith(car, {'rightWheel': {'tire': {'thickness': 32}}}) ``` it doesn't copy `tireRightColor` when creating the new car.