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

Object Serialization to JSON, how to serialize Attributes (like XML)

Apr 18, 2011 at 4:24 AM

Hi Everybody,

I am a Newbie to Json, I just started using Json.NET from today.

I was looking for a way to convert XML to JSON and landed in Json.NET.

I have a class that I serialize to XML and then convert to JSON, but this is hampering performance. So I started using [JsonProperty] attributes inside my class to convert to JSON.

I have few attributes which are a part of XML Element, But How to I serialize XML Attributes from my objects to JSON? We have [XMLAttribute] for this in XML, is there anything equivalent in JSON.NET?

sample object:

<headClass id="123 type="simple">


Thanks in advance