json
                                
                                
                                
                                    json copied to clipboard
                            
                            
                            
                        Isolate fields that exist in the JSON value but were not present in the struct deserialized into
What's the cleanest way to handle a really scary problem I'm sure everyone is aware of:
- You create a struct to deserialize all fields that you think exist in a JSON value
 - Unbeknownst to you, the producer of that JSON value adds new fields to the JSON value that your struct does not account for
 - Your code silently fails by ignoring those fields since they aren't present in the struct you're deserializing into.
 
So how could we use serde_json to obtain a Value containing only the fields that were not present in the struct? It's sort of like a diff showing everything your struct is not accounting for.
My end goal would be to add a field to my struct that is just a String value containing a stringified representation of all fields not accounted for by my struct so that at least as a stop gap I'm not discarding them.