How would I read the "embedded" Json file from the "DataContractJsonSerializer" in C # .NET (win7 phone)?

I have a problem if my json file looks like

{"Numbers": "45387", "Words": "space buckets"}

I can read it just fine, but if it looks like this:

{"Home": {"Numbers": "45387", "Words": "space buckets"},
"Something": {"Numbers": "12345", "Words": "Kransky"}}

I do not receive any information. I have no idea how to switch between Main and Something! Download JSON with this "nested" information using this code,

var ser = new DataContractJsonSerializer(typeof(myInfo));

var info = (myInfo)ser.ReadObject(e.Result); 

// Class used to store my information

[DataContract] 
public class myInfo 
{ 
    [DataMember(Name="Numbers")] 
    public int number 
    { get; set; } 

    [DataMember(Name="Words")] 
    public string words 
    { get; set; } 
} 

.
DataContract, . [DataContract, Name= "Main" ], , .
"main" , . var ser = new DataContractJsonSerializer (typeof (myInfo), "Main" ),
: "Main" ". Encountered" Element " " root ", namespace ''.
json-. json.NET, json . , - !

+3
1

:

[DataContract]
public class Wrapper
{
    [DataMember]
    public myInfo Main { get; set; }

    [DataMember]
    public myInfo Something { get; set; }
}

JSON - .

+5

Source: https://habr.com/ru/post/1781006/


All Articles