Timeline for Serialize Dynamic Property Name for an Object using JSON.NET
Current License: CC BY-SA 3.0
7 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Mar 28, 2014 at 22:39 | vote | accept | JNYRanger | ||
| Mar 28, 2014 at 22:39 | comment | added | JNYRanger | No problem! I wish I could upvote you a second time, thanks so much for this detailed explanation. It has finally solved my issue without a clunky workaround! | |
| Mar 28, 2014 at 21:51 | history | edited | Brian Rogers | CC BY-SA 3.0 |
Added example code
|
| Mar 28, 2014 at 20:55 | comment | added | JNYRanger | Thanks a lot. An example would be very helpful, I've been banging my head against the wall doing research on a workaround and extending the DefaultContractResolver didn't seem like it would really fit my needs, nor did I want to utilize that much reflection in the first place. | |
| Mar 28, 2014 at 20:28 | comment | added | Brian Rogers |
There is a way to write the converter such that the attributes for the properties are still respected (meaning the other converters should get called automatically), but the catch is, you can't put a [JsonConverter] attribute on the parent object or else it will result in a recursive loop as the converter tries to use itself. Give me a few minutes and I'll try to make an example to demonstrate.
|
|
| Mar 28, 2014 at 20:23 | comment | added | JNYRanger | so essentially I need to write a converter for the entire object and using attributes for automatic serialization isn't going to do the trick here? Since I already have a few converters for internal objects, can I call them from the parent converter when I get up to those fields so I don't need to re-write those? | |
| Mar 28, 2014 at 20:19 | history | answered | Brian Rogers | CC BY-SA 3.0 |