Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Convert Json string into Object(s) or Cursor(s)
Message
De
14/05/2020 19:34:57
 
 
À
14/05/2020 17:12:55
Information générale
Forum:
Visual FoxPro
Catégorie:
Web Services
Divers
Thread ID:
01674427
Message ID:
01674430
Vues:
145
Luis,

I checked with nfJson and in fact it's complaining about some trailing commas at the end of some object members. If they are removed from the JSON object, then nfJson tools are able to process the object. I'm sure Marco will have a look into this.

Meanwhile, I tried my JsonToXML class and found out it can process the JSON as you're receiving from your provider. A crude cursor can be created from the XML, if you do not want to inspect / process the XML object directly.
m.jx = CREATEOBJECT("JsonToXML")
m.xml = m.jx.Convert("luis-guerra.json")
? XMLTOCURSOR(STRCONV(m.xml.selectNodes("//array").item(0).xml, 11))
Browse as attached.

>I'm developing a little VFP9 project which consumes a Web Service, this WS has 2 methods, the first method returns a smal Json string which is easily decode into a data record. The second method also returns a Json string. This Json string is much more complex. I tried the vfp_json library and it looks that it doesn't support complex Json strings. I also tried nfJson without success. Does anybody knows about some tools thar can decode the following Json String into VFP cursors or objects that could be used to get the values of each and every record?:
>
>TIA
>
>
>[
>    {
>        "sql_error": "1",
>        "msg_error": "Ok",
>        "guia": "WYB69883941",
>        "movimientos": [
>            {
>                "chk": "CV",
>                "fecha": "02/03/2020",
>                "hora": "19:28",
>                "estado": "VISITADO",
>                "sub_estado": "Coordinacion Posterior",
>                "apunts": "",
>                "agencia": "LIM",
>                "gps_px": "0",
>                "gps_py": "0",
>                "img": []
>            },
>            {
>                "chk": "EB",
>                "fecha": "02/03/2020",
>                "hora": "19:29",
>                "estado": "ENTRO A ALMACEN",
>                "sub_estado": "Custodia Temporal En Almac\u00c3\u00a9N",
>                "apunts": "",
>                "agencia": "LIM",
>                "gps_px": "0",
>                "gps_py": "0"
>            },
>            {
>                "chk": "SB",
>                "fecha": "03/03/2020",
>                "hora": "05:23",
>                "estado": "SALIO DE ALMACEN",
>                "sub_estado": "Salio De Boveda",
>                "apunts": "",
>                "agencia": "LIM",
>                "gps_px": "0",
>                "gps_py": "0"
>            },
>            {
>                "chk": "EN",
>                "fecha": "03/03/2020",
>                "hora": "14:59",
>                "estado": "ENTREGADO",
>                "sub_estado": "Entrega Con Sello",
>                "apunts": "Firma : Sello (DNI:0000)",
>                "agencia": "LIM",
>                "gps_px": "-12.09139",
>                "gps_py": "-77.02647",
>                "img": [
>                    {
>                        "img_path": "6687950_20200303_145359.jpg",
>                        "img_px": "-12.09081",
>                        "img_py": "-77.02716"
>                    },
>                    {
>                        "img_path": "6687950_20200303_145443.jpg",
>                        "img_px": "-12.09081",
>                        "img_py": "-77.02716"
>                    },
>                    {
>                        "img_path": "6687950_20200303_145732.jpg",
>                        "img_px": "-12.09082",
>                        "img_py": "-77.02707"
>                    },
>                ]
>            }
>        ],
>        "img": [
>            {
>                "img_path": "6687950_20200303_145359.jpg",
>                "img_fecha": "03/03/2020",
>                "img_hora": "14:53:59",
>                "n_visita": "2"
>            },
>            {
>                "img_path": "6687950_20200303_145443.jpg",
>                "img_fecha": "03/03/2020",
>                "img_hora": "14:54:43",
>                "n_visita": "2"
>            },
>        ]
>    }
>]
>
----------------------------------
António Tavares Lopes
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform