Class XmlNodeConverter
- Namespace
- Newtonsoft.Json.Converters
- Assembly
- Newtonsoft.Json.dll
Converts XML to and from JSON.
public class XmlNodeConverter : JsonConverter
- Inheritance
-
XmlNodeConverter
- Inherited Members
Constructors
XmlNodeConverter()
public XmlNodeConverter()
Properties
DeserializeRootElementName
Gets or sets the name of the root element to insert when deserializing to XML if the JSON structure has produces multiple root elements.
public string DeserializeRootElementName { get; set; }
Property Value
- string
The name of the deserialize root element.
OmitRootObject
Gets or sets a value indicating whether to write the root JSON object.
public bool OmitRootObject { get; set; }
Property Value
- bool
true
if the JSON root object is omitted; otherwise,false
.
WriteArrayAttribute
Gets or sets a flag to indicate whether to write the Json.NET array attribute. This attribute helps preserve arrays when converting the written XML back to JSON.
public bool WriteArrayAttribute { get; set; }
Property Value
- bool
true
if the array attibute is written to the XML; otherwise,false
.
Methods
CanConvert(Type)
Determines whether this instance can convert the specified value type.
public override bool CanConvert(Type valueType)
Parameters
valueType
TypeType of the value.
Returns
- bool
true
if this instance can convert the specified value type; otherwise,false
.
ReadJson(JsonReader, Type, object, JsonSerializer)
Reads the JSON representation of the object.
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
Parameters
reader
JsonReaderThe JsonReader to read from.
objectType
TypeType of the object.
existingValue
objectThe existing value of object being read.
serializer
JsonSerializerThe calling serializer.
Returns
- object
The object value.
WriteJson(JsonWriter, object, JsonSerializer)
Writes the JSON representation of the object.
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
Parameters
writer
JsonWriterThe JsonWriter to write to.
value
objectThe value.
serializer
JsonSerializerThe calling serializer.