c# - ServiceStack.Text and DeserializeFromString where Json names are illegal -


i've been using servicestack.text deserializefromstring long time, in new project i've hit issue.

the json need parse objects has following format:

{"http://someurl.com/":{"http://otherurl.org/schema#name":[{"value":"val1","type":"val2"}]}} 

so object name prefixed url, can't match class member name. i've tried using datacontract map names, returns null objects.

is there way of doing using servicestack.text, or need parse json manually?

any appreciated.

edit:

with bit of playing about, managed solve issue using datacontract attributes. failing because classes specified weren't prefixed correctly. managed solve so:

[datacontract] public class schools {     [datamember(name = "http://demo.talisaspire.com/")]     public items items { get; set; } }  [datacontract] public class items {      [datamember(name = "http://purl.org/vocab/aiiso/schema#code")]     public ienumerable<element> code { get; set; }      [datamember(name = "http://purl.org/vocab/aiiso/schema#knowledgegrouping")]     public ienumerable<element> knowledgegrouping { get; set; }      [datamember(name = "http://purl.org/vocab/aiiso/schema#name")]     public ienumerable<element> name { get; set; }      [datamember(name = "http://purl.org/vocab/aiiso/schema#organizationalunit")]     public ienumerable<element> organizationalunit { get; set; }      [datamember(name = "http://www.w3.org/1999/02/22-rdf-syntax-ns#type")]     public ienumerable<element> type { get; set; }  }  public class element {     public string type { get; set; }     public string value { get; set; } }  

it easier parse manually can with:

var obj = jsonobject.parse(json)     .object("http://someurl.com/");  var items = obj.arrayobjects("http://otherurl.org/schema#name")[0];  var value = items["value"]; //= val1 var type = items["type"];   //= val2 

Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - Chrome Extension: Interacting with iframe embedded within popup -