This project has moved. For the latest updates, please go here.

Deserializing Public Properties w/ Private / Protected Set No Longer Works

Aug 6, 2010 at 11:19 PM
In Release 7 you used to be able to serialize / deserialize public properties with a non public setter. As of the latest revision, you can still serialize these members, but *De*serializing them doesn't work. Was this intentional? Should I create an issue? I really would like to leverage the TypeMemberHandling.Auto functionality but for now I will have to revert...
Aug 6, 2010 at 11:33 PM
Belay that... it might have been a release older than 7. I am not sure because I usually get the binaries from another OSS.
Aug 7, 2010 at 4:08 AM
Edited Aug 9, 2010 at 1:19 AM

Json.NET now only serializes/deserializes public properties and fields by default. Internal, protected and private members need to be marked with [JsonProperty] to be serialized and deserialized.

If you don't want to add attributes to your objects then another option is to set DefaultMemberSearchFlags on DefaultContractResolver and pass that to JsonConvert/JsonSerializer.