Serializing null values from a REST API response
I recently used WCF to use REST API. I used entity class to serialize REST XML Reponse, here I have a problem:
<grid-cell-size type="decimal" nil="true"/>
and in my C # class:
[XmlElement("grid-cell-size")]
public decimal? GridCellSize { get; set; }
but the result of the Input line was not in the correct format. error message.
How can I change my C # code to accept null values from XML?
0
a source to share
1 answer
Try adding the prefix "xsi": instead of
<grid-cell-size type="decimal" nil="true"/>
using
<grid-cell-size xsi:type="decimal" xsi:nil="true"/>
of course - don't forget to add the namespace to the main node: xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" xmlns: xsd = "http://www.w3.org/2001/XMLSchema "
namespace declarations (if not already declared)
0
a source to share