c# - How to rename and remap fields with illegal json field names -
i have used json2csharp produce nice c# class can deserialize json.
it working expected except json2csharp named of fields invalid_name . renamed valid csharp names when serialized class null.
i found this other post... 1 of answerers said following...
keep in mind class have pasted below not work directly, because of naming of of fields in json. may have rename them manually , map them.
this describes problem. unfortunately, reply gives no clues on how "map them." can tell me how manually map json arrays c# classes.
i using restsharp deserializers, btw.
any ideas?
if using json.net basis or json parsing, can rename properties , decorate them attributes align them original json object.
an illustration property in json called 1 invalid in c#. can corrected using following:
[jsonproperty("1")] public int? 1 { get; set; }
there jsonobject attribute if want edit @ class level, , jsonignore object ignore serialisation of properties.
c# json deserialization restsharp json2csharp
No comments:
Post a Comment