Got json parsing working

This commit is contained in:
ronreg-ribdev 2020-05-26 02:21:13 -07:00
parent a06ab76385
commit f026e0058b

View File

@ -126,15 +126,31 @@
++ parse-request-stations-response ++ parse-request-stations-response
|= response=client-response:iris |= response=client-response:iris
^- json ^- json
=/ pairs pairs:enjs:format =, format
?. ?=(%finished -.response) ?. ?=(%finished -.response)
%- pairs [fulltext+s+'bart response error' ~] %- pairs:enjs [fulltext+s+'bart response error' ~]
=/ data=(unit mime-data:iris) full-file.response =/ data=(unit mime-data:iris) full-file.response
?~ data %- pairs ~ ?~ data %- pairs:enjs ~
=/ ujon=(unit json) (de-json:html q.data.u.data) =/ ujon=(unit json) (de-json:html q.data.u.data)
?~ ujon %- pairs ~ ?~ ujon %- pairs:enjs ~
?> ?=(%o -.u.ujon)
=/ parsed-json u.ujon =/ parsed-json u.ujon
parsed-json =/ root=json (~(got by p.parsed-json) 'root')
?> ?=(%o -.root)
=/ stations (~(got by p.root) 'stations')
?> ?=(%o -.stations)
=/ station=json (~(got by p.stations) 'station')
?> ?=(%a -.station)
=/ inner p.station
=/ abbr-and-name %- turn :- inner |= item=json
^- json
?> ?=(%o -.item)
=/ name (~(got by p.item) 'name')
?> ?=(%s -.name)
=/ abbr (~(got by p.item) 'abbr')
?> ?=(%s -.abbr)
(pairs:enjs [name+s+p.name abbr+s+p.abbr ~])
a+abbr-and-name
:: ::
++ poke-handle-http-request ++ poke-handle-http-request
|= =inbound-request:eyre |= =inbound-request:eyre