Readdy Write  
0,00 €
Your View Money
Views: Count
Self 20% 0
Your Content 60% 0

Users by Links 0
u1*(Content+Views) 10% 0
Follow-Follower 0
s2*(Income) 5% 0

Count
Followers 0
Login Register as User

UWP Beispiel: Json Strings auswerten

26.06.2018 (👁3834)

UWP Beispiel: Json Strings

Dieses Beispiel zeigt den Inhalt des UWP Samples: Json

Dabei wird der fogende String im Json Format analysiert

{  "id": "1146217767",   "phone": null,   "name": "Satya Nadella",   "education": [     {       "school": {         "id": "204165836287254",         "name": "Contoso High School"       },       "type": "High School"     },     {       "school": {         "id": "116138758396662",         "name": "Contoso University"       },       "type": "College"     }   ],   "timezone": -8,   "verified": true }

 

Funktionsweise des Codes

Die Funktionsweise findet man in School.cs

Dabei wird aus dem Eingabestring ein JsonObject erstellt mit jsonObject.GetNamedObject(KeyName,null)

private const string idKey = "id";

private const string schoolKey = "school";

private const string nameKey = "name";

private const string typeKey = "type";

 

private string id;

private string name;

private string type;

 

public School()

{

    Id = "";

    Name = "";

    Type = "";

}

 

public School(JsonObject jsonObject)

{

    JsonObject schoolObject = jsonObject.GetNamedObject(schoolKey, null);

    if (schoolObject != null)

    {

        Id = schoolObject.GetNamedString(idKey, "");

        Name = schoolObject.GetNamedString(nameKey, "");

    }

    Type = jsonObject.GetNamedString(typeKey);

}

Man findet das UWP Json beispiel unter:

https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/Json

Unter Windows Universal Master Samples