Who maintains JSON.lua?

Moderator: leecollings

Post Reply
User avatar
Westcott
Posts: 423
Joined: Tuesday 09 December 2014 17:04
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: UK - Glos
Contact:

Who maintains JSON.lua?

Post by Westcott »

I'm asking because JSON:decode fails to correctly decode this data -

Code: Select all

{
   "geocoded_waypoints" : [
      {
         "geocoder_status" : "OK",
         "place_id" : "ChIJ0cQ_9DGLJRMR7n5e8xh14BA",
         "types" : [ "route" ]
      },
      {
         "geocoder_status" : "OK",
         "place_id" : "EiZWaWEgTGlzaXBwbywgMzMsIDAwMTI1IFJvbWEgUk0sIEl0YWxpYQ",
         "types" : [ "street_address" ]
      }
   ],
   "routes" : [
      {
         "bounds" : {
            "northeast" : {
               "lat" : 41.8234588,
               "lng" : 12.4443676
            },
            "southwest" : {
               "lat" : 41.7633485,
               "lng" : 12.3608935
            }
         },
         "copyrights" : "Map data ©2016 Google",
         "legs" : [
            {
               "distance" : {
                  "text" : "12.7 km",
                  "value" : 12736
               },
               "duration" : {
                  "text" : "18 mins",
                  "value" : 1105
               },
               "end_address" : "Via Lisippo, 33, 00125 Roma RM, Italy",
               "end_location" : {
                  "lat" : 41.765307,
                  "lng" : 12.3677014
               },
               "start_address" : "Via Madras, 00144 Roma, Italy",
               "start_location" : {
                  "lat" : 41.8234588,
                  "lng" : 12.4437439
               },
               "steps" : [
                  {
                     "distance" : {
                        "text" : "75 m",
                        "value" : 75
                     },
                     "duration" : {
                        "text" : "1 min",
                        "value" : 12
                     },
                     "end_location" : {
                        "lat" : 41.8229705,
                        "lng" : 12.4443676
                     },
                     "html_instructions" : "Head \u003cb\u003esouth-east\u003c/b\u003e on \u003cb\u003eVia Madras\u003c/b\u003e towards \u003cb\u003eVia Calcutta\u003c/b\u003e",
                     "polyline" : {
                        "points" : "ssg~Fkl}jA`B}B"
                     },
                     "start_location" : {
                        "lat" : 41.8234588,
                        "lng" : 12.4437439
                     },
                     "travel_mode" : "DRIVING"
                  },
                  {
                     "distance" : {
                        "text" : "0.2 km",
                        "value" : 177
                     },
                     "duration" : {
                        "text" : "1 min",
                        "value" : 39
                     },
                     "end_location" : {
                        "lat" : 41.8218415,
                        "lng" : 12.4428597
                     },
                     "html_instructions" : "Turn \u003cb\u003eright\u003c/b\u003e onto \u003cb\u003eVia Calcutta\u003c/b\u003e",
                     "maneuver" : "turn-right",
                     "polyline" : {
                        "points" : "qpg~Fip}jAbAtA|CvE"
                     },
                     "start_location" : {
                        "lat" : 41.8229705,
                        "lng" : 12.4443676
                     },
                     "travel_mode" : "DRIVING"
                  },
                  {
                     "distance" : {
                        "text" : "0.2 km",
                        "value" : 218
                     },
                     "duration" : {
                        "text" : "1 min",
                        "value" : 38
                     },
                     "end_location" : {
                        "lat" : 41.8234028,
                        "lng" : 12.4412691
                     },
                     "html_instructions" : "Turn \u003cb\u003eright\u003c/b\u003e onto \u003cb\u003eVia di Decima\u003c/b\u003e",
                     "maneuver" : "turn-right",
                     "polyline" : {
                        "points" : "oig~F{f}jAQRyC|CkBjB_@^"
                     },
                     "start_location" : {
                        "lat" : 41.8218415,
                        "lng" : 12.4428597
                     },
                     "travel_mode" : "DRIVING"
                  },
                  {
                     "distance" : {
                        "text" : "2.3 km",
                        "value" : 2254
                     },
                     "duration" : {
                        "text" : "3 mins",
                        "value" : 185
                     },
                     "end_location" : {
                        "lat" : 41.809821,
                        "lng" : 12.4216147
                     },
                     "html_instructions" : "Turn \u003cb\u003eleft\u003c/b\u003e onto \u003cb\u003eVia Ostiense\u003c/b\u003e/\u003cb\u003eSS8bis\u003c/b\u003e",
                     "maneuver" : "turn-left",
                     "polyline" : {
                        "points" : "gsg~F}||jA`EbGdChD~A`C`ChDvAnBjBlCX`@NTj@z@z@lAV^xA`CpAlBz@nAhChD|@xAPd@\\h@f@v@nIpMvAtBX`@PR@FBDFLpG`Jf@r@NPTb@DHBFDLDP@L@N@LAL?F?RA\\Ep@?Z?X@LDZBJHRXj@\\p@`@n@V`@LN|@nAv@bAz@jAdAxARTDF"
                     },
                     "start_location" : {
                        "lat" : 41.8234028,
                        "lng" : 12.4412691
                     },
                     "travel_mode" : "DRIVING"
                  },
                  {
                     "distance" : {
                        "text" : "0.7 km",
                        "value" : 671
                     },
                     "duration" : {
                        "text" : "1 min",
                        "value" : 52
                     },
                     "end_location" : {
                        "lat" : 41.8043446,
                        "lng" : 12.4182687
                     },
                     "html_instructions" : "Keep \u003cb\u003eleft\u003c/b\u003e at the fork to continue on \u003cb\u003eExits E 45-E 80\u003c/b\u003e, follow signs for \u003cb\u003eNapoli\u003c/b\u003e/\u003cb\u003eL'Aquila\u003c/b\u003e",
                     "maneuver" : "fork-left",
                     "polyline" : {
                        "points" : "k~d~FabyjArBfBLJHFZPRJJFbAf@bCdAx@Zx@`@tDdB^R`@Tx@^fAf@vBdA\\Pr@\\"
                     },
                     "start_location" : {
                        "lat" : 41.809821,
                        "lng" : 12.4216147
                     },
                     "travel_mode" : "DRIVING"
                  },
                  {
                     "distance" : {
                        "text" : "0.2 km",
                        "value" : 212
                     },
                     "duration" : {
                        "text" : "1 min",
                        "value" : 19
                     },
                     "end_location" : {
                        "lat" : 41.8025247,
                        "lng" : 12.4179642
                     },
                     "html_instructions" : "Keep \u003cb\u003eright\u003c/b\u003e at the fork, follow signs for \u003cb\u003eOstia\u003c/b\u003e",
                     "maneuver" : "fork-right",
                     "polyline" : {
                        "points" : "c|c~FemxjAXX@?DB@?PJn@JRDPA\\CNCNENGHCNCNAR@TB\\L^N"
                     },
                     "start_location" : {
                        "lat" : 41.8043446,
                        "lng" : 12.4182687
                     },
                     "travel_mode" : "DRIVING"
                  },
                  {
                     "distance" : {
                        "text" : "0.3 km",
                        "value" : 297
                     },
                     "duration" : {
                        "text" : "1 min",
                        "value" : 22
                     },
                     "end_location" : {
                        "lat" : 41.7999684,
                        "lng" : 12.4171502
                     },
                     "html_instructions" : "Keep \u003cb\u003eright\u003c/b\u003e to continue on \u003cb\u003eVia Ostiense\u003c/b\u003e/\u003cb\u003eSS8bis\u003c/b\u003e",
                     "maneuver" : "keep-right",
                     "polyline" : {
                        "points" : "wpc~FgkxjAx@Zz@Z~Bz@f@Px@Xd@H\\Jf@EDA`@EHAFC"
                     },
                     "start_location" : {
                        "lat" : 41.8025247,
                        "lng" : 12.4179642
                     },
                     "travel_mode" : "DRIVING"
                  },
                  {
                     "distance" : {
                        "text" : "88 m",
                        "value" : 88
                     },
                     "duration" : {
                        "text" : "1 min",
                        "value" : 6
                     },
                     "end_location" : {
                        "lat" : 41.7991878,
                        "lng" : 12.417332
                     },
                     "html_instructions" : "Continue straight onto \u003cb\u003eVia Massa Lombarda\u003c/b\u003e",
                     "maneuver" : "straight",
                     "polyline" : {
                        "points" : "y`c~FefxjA^E@?`@ENCNCv@O"
                     },
                     "start_location" : {
                        "lat" : 41.7999684,
                        "lng" : 12.4171502
                     },
                     "travel_mode" : "DRIVING"
                  },
                  {
                     "distance" : {
                        "text" : "1.1 km",
                        "value" : 1127
                     },
                     "duration" : {
                        "text" : "1 min",
                        "value" : 84
                     },
                     "end_location" : {
                        "lat" : 41.7899685,
                        "lng" : 12.4227357
                     },
                     "html_instructions" : "Continue onto \u003cb\u003eVia di Mezzocammino\u003c/b\u003e",
                     "polyline" : {
                        "points" : "}{b~FigxjA`FaAbASNCHCDCnD{BjGwEDChG_Cd@Qf@S\\OPElAg@pEgBf@]t@k@`GoEb@Y"
                     },
                     "start_location" : {
                        "lat" : 41.7991878,
                        "lng" : 12.417332
                     },
                     "travel_mode" : "DRIVING"
                  },
                  {
                     "distance" : {
                        "text" : "0.2 km",
                        "value" : 236
                     },
                     "duration" : {
                        "text" : "1 min",
                        "value" : 28
                     },
                     "end_location" : {
                        "lat" : 41.7887486,
                        "lng" : 12.4249421
                     },
                     "html_instructions" : "Turn \u003cb\u003eleft\u003c/b\u003e to stay on \u003cb\u003eVia di Mezzocammino\u003c/b\u003e",
                     "maneuver" : "turn-left",
                     "polyline" : {
                        "points" : "iba~FciyjACQ?E?EFMJUvBwFn@oALQJKBCDCDCPC"
                     },
                     "start_location" : {
                        "lat" : 41.7899685,
                        "lng" : 12.4227357
                     },
                     "travel_mode" : "DRIVING"
                  },
                  {
                     "distance" : {
                        "text" : "4.4 km",
                        "value" : 4376
                     },
                     "duration" : {
                        "text" : "4 mins",
                        "value" : 256
                     },
                     "end_location" : {
                        "lat" : 41.7660017,
                        "lng" : 12.3842318
                     },
                     "html_instructions" : "Slight \u003cb\u003eright\u003c/b\u003e onto \u003cb\u003eVia C. Colombo\u003c/b\u003e",
                     "maneuver" : "turn-slight-right",
                     "polyline" : {
                        "points" : "uz`~F{vyjAd@BLRLRJRx@nAHLLTNXTh@x@zBh@nBr@lCVnAHb@Jz@ZnD^dFNlB@HFz@Dr@@jA?x@C`CGtC?BA~B?zAFxBBx@HnAL~@PnAX|At@hEF\\^nAFV\\dAL^\\bAf@nATj@f@`Ah@~@LTXb@n@~@PV@@LPnUl\\vB|C`FdH~DxFvDlFlAdBv@hAh@|@b@l@LNzPhVdB`Cx\\~e@dClDxB~C"
                     },
                     "start_location" : {
                        "lat" : 41.7887486,
                        "lng" : 12.4249421
                     },
                     "travel_mode" : "DRIVING"
                  },
                  {
                     "distance" : {
                        "text" : "0.1 km",
                        "value" : 143
                     },
                     "duration" : {
                        "text" : "1 min",
                        "value" : 23
                     },
                     "end_location" : {
                        "lat" : 41.7651802,
                        "lng" : 12.3829681
                     },
                     "html_instructions" : "Turn \u003cb\u003eright\u003c/b\u003e to stay on \u003cb\u003eVia C. Colombo\u003c/b\u003e",
                     "maneuver" : "turn-right",
                     "polyline" : {
                        "points" : "ol|}FmxqjAAJ?B?B@DBJ@D@BNVX`@b@j@b@l@V`@PT"
                     },
                     "start_location" : {
                        "lat" : 41.7660017,
                        "lng" : 12.3842318
                     },
                     "travel_mode" : "DRIVING"
                  },
                  {
                     "distance" : {
                        "text" : "0.9 km",
                        "value" : 862
                     },
                     "duration" : {
                        "text" : "1 min",
                        "value" : 77
                     },
                     "end_location" : {
                        "lat" : 41.7698355,
                        "lng" : 12.3746632
                     },
                     "html_instructions" : "\u003cb\u003eVia C. Colombo\u003c/b\u003e turns \u003cb\u003eright\u003c/b\u003e and becomes \u003cb\u003eVia di Acilia\u003c/b\u003e",
                     "polyline" : {
                        "points" : "kg|}FqpqjAcB~DUd@cBnD[n@qDxHo@rAyA`DwApCOXsA~Cu@hBa@z@i@fAo@lA"
                     },
                     "start_location" : {
                        "lat" : 41.7651802,
                        "lng" : 12.3829681
                     },
                     "travel_mode" : "DRIVING"
                  },
                  {
                     "distance" : {
                        "text" : "0.1 km",
                        "value" : 109
                     },
                     "duration" : {
                        "text" : "1 min",
                        "value" : 17
                     },
                     "end_location" : {
                        "lat" : 41.7694983,
                        "lng" : 12.3735714
                     },
                     "html_instructions" : "Turn \u003cb\u003eleft\u003c/b\u003e onto \u003cb\u003eVia Posidippo\u003c/b\u003e",
                     "maneuver" : "turn-left",
                     "polyline" : {
                        "points" : "od}}Fs|ojAQ`@HN@DTZNp@DTFNTl@"
                     },
                     "start_location" : {
                        "lat" : 41.7698355,
                        "lng" : 12.3746632
                     },
                     "travel_mode" : "DRIVING"
                  },
                  {
                     "distance" : {
                        "text" : "0.1 km",
                        "value" : 112
                     },
                     "duration" : {
                        "text" : "1 min",
                        "value" : 21
                     },
                     "end_location" : {
                        "lat" : 41.7693193,
                        "lng" : 12.3724474
                     },
                     "html_instructions" : "\u003cb\u003eVia Posidippo\u003c/b\u003e turns \u003cb\u003eright\u003c/b\u003e and becomes \u003cb\u003ePiazza Eschilo\u003c/b\u003e",
                     "polyline" : {
                        "points" : "kb}}FyuojAEJGLKXANCLAH?F@J@D@@@@@D@BBDBDHNFJPZBDHP"
                     },
                     "start_location" : {
                        "lat" : 41.7694983,
                        "lng" : 12.3735714
                     },
                     "travel_mode" : "DRIVING"
                  },
                  {
                     "distance" : {
                        "text" : "1.0 km",
                        "value" : 1046
                     },
                     "duration" : {
                        "text" : "2 mins",
                        "value" : 114
                     },
                     "end_location" : {
                        "lat" : 41.7653166,
                        "lng" : 12.3610353
                     },
                     "html_instructions" : "Continue straight onto \u003cb\u003eVia Euripide\u003c/b\u003e",
                     "maneuver" : "straight",
                     "polyline" : {
                        "points" : "ga}}FynojAVp@FRr@|CjAxExAbGJb@R|@DNf@pBJj@^|Al@`CBNTz@T~@`AtDvAbGj@|Bf@vBVdAp@bCTp@"
                     },
                     "start_location" : {
                        "lat" : 41.7693193,
                        "lng" : 12.3724474
                     },
                     "travel_mode" : "DRIVING"
                  },
                  {
                     "distance" : {
                        "text" : "0.4 km",
                        "value" : 369
                     },
                     "duration" : {
                        "text" : "1 min",
                        "value" : 50
                     },
                     "end_location" : {
                        "lat" : 41.7635545,
                        "lng" : 12.3644474
                     },
                     "html_instructions" : "At the roundabout, take the \u003cb\u003e3rd\u003c/b\u003e exit onto \u003cb\u003eVia Focilide\u003c/b\u003e",
                     "maneuver" : "roundabout-right",
                     "polyline" : {
                        "points" : "gh|}FogmjA?@?B?@?@?@?@?@@??@?@@@?@@??@@??@@?@?@@@?@??A@?@??A@?@A?A@??A@??A?A?A@??A?A?A?A?AJS?IDGn@oA@GTm@N]L[Zo@Pa@x@}B`BwF"
                     },
                     "start_location" : {
                        "lat" : 41.7653166,
                        "lng" : 12.3610353
                     },
                     "travel_mode" : "DRIVING"
                  },
                  {
                     "distance" : {
                        "text" : "51 m",
                        "value" : 51
                     },
                     "duration" : {
                        "text" : "1 min",
                        "value" : 16
                     },
                     "end_location" : {
                        "lat" : 41.7633485,
                        "lng" : 12.364991
                     },
                     "html_instructions" : "Continue onto \u003cb\u003eVia Stesicoro\u003c/b\u003e",
                     "polyline" : {
                        "points" : "e}{}Fy|mjAT{@Nk@@C"
                     },
                     "start_location" : {
                        "lat" : 41.7635545,
                        "lng" : 12.3644474
                     },
                     "travel_mode" : "DRIVING"
                  },
                  {
                     "distance" : {
                        "text" : "0.3 km",
                        "value" : 313
                     },
                     "duration" : {
                        "text" : "1 min",
                        "value" : 46
                     },
                     "end_location" : {
                        "lat" : 41.765307,
                        "lng" : 12.3677014
                     },
                     "html_instructions" : "Turn \u003cb\u003eleft\u003c/b\u003e onto \u003cb\u003eVia Lisippo\u003c/b\u003e",
                     "maneuver" : "turn-left",
                     "polyline" : {
                        "points" : "}{{}Fe`njAqHgLuAuB"
                     },
                     "start_location" : {
                        "lat" : 41.7633485,
                        "lng" : 12.364991
                     },
                     "travel_mode" : "DRIVING"
                  }
               ],
               "via_waypoint" : []
            }
         ],
         "overview_polyline" : {
            "points" : "ssg~Fkl}jA`B}BbAtA|CvEQReGhG_@^`EbGdChD~A`CxExG`E`GrAlBjDnFz@nAhChD|@xAPd@dA`BfLfQj@t@DLpItLZl@HTF^B\\CfAElA@f@Hf@b@~@~@`Bd@p@vFxHX\\`CrBdAl@zHjDpHnD~DlBpAn@b@\\PJn@Jd@Bl@G^MXGb@?r@PxAj@|GbCbATl@Gr@KrAOlJiBXGtD_CpG{EnHqCdDqApEgBf@]vH{Fb@YCQ?KRc@vBwFn@oAX]HGVGd@BLRXf@bA|A\\n@nAdD|A|F`@rBf@jFn@rIHdAF~BKtIAzEJrDVnCj@lD|@fFf@fBj@dBdArC|@lBv@tA|A|Bv`@bk@|NvSh@|@b@l@hQxV~g@nt@?XDPPZxB|CPTcB~DyBtEwI~QgBjDiChGkAbCaAnBJTTZNp@Ld@Tl@EJSf@E\\APBPFLXf@T`@`@bAz@pDdD|MlAbF|AzGdEtP|C~LTr@?D?B@DDFFBFCDI@IJUDQp@wAd@kAh@kAjA_DhCcJgK}O"
         },
         "summary" : "Via C. Colombo",
         "warnings" : [],
         "waypoint_order" : []
      }
   ],
   "status" : "OK"
}
Thanks.
Zwave - Sigma Z+ stick, Fibaro, Horstmann, Neo Coolcam, EUROtronic
RFlink - IR detectors and temperatures
Wifi - YeeLights, ESP32s, Anoop sockets
Zigbee - lots with zigbee2mqtt and ZbBridge
User avatar
Westcott
Posts: 423
Joined: Tuesday 09 December 2014 17:04
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: UK - Glos
Contact:

Re: Who maintains JSON.lua?

Post by Westcott »

I've solved this problem - JSON.lua is working perfectly.
The JSON data caused extra levels to be decoded.
So I had to change -
distance = data.routes.legs.distance.text
to -
distance = data.routes[1].legs[1].distance.text
Zwave - Sigma Z+ stick, Fibaro, Horstmann, Neo Coolcam, EUROtronic
RFlink - IR detectors and temperatures
Wifi - YeeLights, ESP32s, Anoop sockets
Zigbee - lots with zigbee2mqtt and ZbBridge
jmleglise
Posts: 192
Joined: Monday 12 January 2015 23:27
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.1
Location: FRANCE
Contact:

Re: Who maintains JSON.lua?

Post by jmleglise »

Hi,

For next time, the author is http://regex.info/blog/lua/json

And you can share your experience here : https://www.domoticz.com/wiki/Lua_-_json.lua
My script : https://github.com/jmleglise
RFXTRX433E: Blind Somfy RTS, Portal Somfy Evolvia, chacon IO, Oregon, PIR sensor PT2262
My Last project : Location de vacances a Ouistreham vue mer
KMTronic USB relay
Chinese Z-WAVE: Neo CoolCam
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest