3

I have an xml document that i want to convert to JSON using a JSON Schema.

I am able to convert/serialize the xml into JSON using Newtonsoft.JSON

the code i use to convert it into JSON is JsonConvert.SerializeObject(xmlDocumentObject);

the thing is if there is an array object and it has only one element, then NewtonSoft JSON Serializer converts it into an object rather than an array.

so i've generated a valid json schema out of my JSON and i want to convert the xml document using this json schema. is there a way i can do this using NewtonSoft JSON?

i can see they have a JSchema class that is used to validate a json using a schema but is there a way to convert an object into json using the same schema object?

  • Have you reviewed [Convert JSON to XML or XML to JSON](http://stackoverflow.com/questions/814001/convert-json-to-xml-or-xml-to-json)? – ToddB Apr 08 '16 at 18:32
  • @ToddB I've read that already but my problem is different. i need to convert it using a schema. the thing is it doesn't recognize arrays if there is only one element in the array. – Silent Hunter Apr 08 '16 at 18:51

0 Answers0