I am trying to convert the following json into a domain object .
JSON:
[{"name":"McDonalds","deals":[{"desc":"Onion Rings free with Double Cheese burgers"}],"geometry":{"lat":13.073412,"lng":80.221393}},{"name":"JusSportz","deals":[{"desc":"20% off on Wilson Rackets"}],"geometry":{"lat":13.073231,"lng":80.221181}}]
Model:
[DataContract]
public class Deal
{
[DataMember(Name="name")]
public string Store { get; set; }
[DataMember(Name="deals")]
public Offer[] Offers {get; set;}
[DataMember(Name="geometry")]
public GeoCoordinate Location { get; set; }
}
[DataContract]
public class Offer
{
[DataMember]
public string deal;
}
I tried the DataContractJsonSerializer that is in the System.Runtime.Serialization.Json namespace and there is apparently no way to convert a string into an object. Are there any other libraries which allow me to get this done? Or is there a way to get this done using this library (by converting the Json string to some intermediate format.)?
Here’s how I deserialize JSON back to my domain objects.
Is this what you were looking for?