Click here to Skip to main content
15,745,973 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How we can assign different name for property during serialization in JSON.
Eg. My class have following structure

public class std
public int no {get;set;}
public string name {get;set;}
public string add {get;set;}

During json serialization (at run time) i wants name s1 for first property(no),s2 for second property (name) and s3 for third property (add).

i found mechanism that i can use attribute [JsonProperty(PropertyName = "S1")]
at time of declaration.

but my requirement assign different name during serialization(At run time).
i am using JSON with C#.

Thanks in advance.
George Swan 20-Feb-15 13:46pm    
</p>Why not declare a new serializable class and pass the std class into its constructor to initialise the class properties that you want? Then serialise the new class.</p>
Sudheer Kumar Tiwari 25-Feb-15 5:53am    
Hi George
please share sample code or related url.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900