locked
Newtonsoft.Json.JsonConvert.deserializeXmlNode is changing the date format RRS feed

  • Question

  • User-141015786 posted

    Hi All,

    I have the Json data of the below xml(created using SerializeXmlNode() method).

    <sample>
         <Identity>
            <vType>Date</vType>
           <Value xsi:type="xsd:dateTime">2016-11-22T21:30:00+05:30</Value>

        <Identity>

    </sample>

    Now when i try to convert this json data to xml format by calling the code below the date format is getting changed.

    XmlDocument xmlDocument = JsonConvert.DeserializeXmlNode(data);
    xml = xmlDocument.OuterXml;

     See the date in bold in the below xml is as below:

    <sample>
         <Identity>
            <vType>Date</vType>
           <Value xsi:type="xsd:dateTime">11/22/2016 9:30:00 PM</Value>     (Note: date in actual xml and in json is 2016-11-22T21:30:00+05:30)

        <Identity>

    </sample>

    Is it an issue with the DeserializeXmlNode() method or is there a way to retain the exact format.

    Regards,

    Sunanda.

    Friday, November 25, 2016 5:55 PM

All replies

  • User-1838255255 posted

    Hi SunandaVarma,

    According to your description, I make a test in myside, it run perfect. As far as I know, when use datetime then convert json to xml or xml to json , it is easy occur error. So I suggest you can modify datetime type to string type, when you want to use it, you can translate it to datetime format!

    Best Regards,

    Eric Du

       

    Monday, November 28, 2016 11:09 AM