-
-
Notifications
You must be signed in to change notification settings - Fork 84
Description
In my attempt to update to [email protected] I noticed that nested JSON support is gone, with a changelog stating that:
json::nestedcan be replaced with#[serde_as(as = "json::JsonString")].
It doesn't seem quite as simple as that though, as I can't figure out a way to achieve what worked with json::nested using JsonString.
Minimal example which contains example JSON files and tests: https://github.com/ljoonal/serde_with_nested_json
running 4 tests
test enum_nested_json ... ok
test struct_json_string ... ok
test enum_json_string ... FAILED
test struct_nested_json ... okfailures:
---- enum_json_string stdout ----
thread 'enum_json_string' panicked at 'calledResult::unwrap()on anErrvalue: Error("invalid type: string "{\"id\":\"R-5c5d3057-bb97-4c31-a2e0-26ea055b2bcf\"}", expected struct MessagePayload", line: 6, column: 2)', src/lib.rs:32:70
My expectation is that JsonString should work just like json:nested did, but instead it fails for a reason that is beyond my debugging skills. But I've at least narrowed it down to working with the structs but breaking with the enums in the linked example repo.
As to why support for this would be nice, a real world usecase is de-serializing an external JSON API's responses that contain nested json of different types, but also sometimes just plain strings.