[chronojump] Receives the JSON from the server as an object instead	of array.
- From: Carles Pina i Estany <carlespina src gnome org>
 
- To: commits-list gnome org
 
- Cc: 
 
- Subject: [chronojump] Receives the JSON from the server as an object instead	of array.
 
- Date: Mon,  5 Jun 2017 19:38:47 +0000 (UTC)
 
commit 96256cd0aace128e10ba5c857ffd51359f848657
Author: Carles Pina i Estany <carles pina cat>
Date:   Mon Jun 5 15:37:36 2017 -0400
    Receives the JSON from the server as an object instead of array.
    
    This needs chronojump-server at least commit
    3bfa76fa9a813e68170fac9f9cfefbb161286719 .
 src/json.cs |   21 +++++++++------------
 1 files changed, 9 insertions(+), 12 deletions(-)
---
diff --git a/src/json.cs b/src/json.cs
index 040553f..b687c31 100644
--- a/src/json.cs
+++ b/src/json.cs
@@ -339,19 +339,16 @@ public class Json
        }
        public double LastPersonByRFIDWeight = 0;
        public string LastPersonByRFIDImageURL = "";
-       private Person personDeserialize(string strPeople)
+       private Person personDeserialize(string strPerson)
        {
-               JsonValue jsonPeople = JsonValue.Parse(strPeople);
-
-               // We receive a list of people but we are interested only on the first one (?)
-               JsonValue person = jsonPeople [0];
-
-               Int32 id = person [0];
-               string player = person [1];
-               double weight = person [2];
-               double height = person [3];
-               string rfid = person [4];
-               string image = person [5];
+               JsonValue jsonPerson = JsonValue.Parse(strPerson);
+
+               Int32 id = jsonPerson ["id"];
+               string player = jsonPerson ["name"];
+               double weight = jsonPerson ["weight"];
+               double height = jsonPerson ["height"];
+               string rfid = jsonPerson ["rfid"];
+               string image = jsonPerson ["imageName"];
 
                LastPersonByRFIDWeight = weight;
                LastPersonByRFIDImageURL = image;
[
Date Prev][
Date Next]   [
Thread Prev][
Thread Next]   
[
Thread Index]
[
Date Index]
[
Author Index]