From f026e0058be7e168466a395a017b142c946306b6 Mon Sep 17 00:00:00 2001 From: ronreg-ribdev <56719257+ronreg-ribdev@users.noreply.github.com> Date: Tue, 26 May 2020 02:21:13 -0700 Subject: [PATCH] Got json parsing working --- urbit/app/bartinfo.hoon | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/urbit/app/bartinfo.hoon b/urbit/app/bartinfo.hoon index 6ac8bc0..f45845b 100644 --- a/urbit/app/bartinfo.hoon +++ b/urbit/app/bartinfo.hoon @@ -126,15 +126,31 @@ ++ parse-request-stations-response |= response=client-response:iris ^- json - =/ pairs pairs:enjs:format + =, format ?. ?=(%finished -.response) - %- pairs [fulltext+s+'bart response error' ~] + %- pairs:enjs [fulltext+s+'bart response error' ~] =/ data=(unit mime-data:iris) full-file.response - ?~ data %- pairs ~ + ?~ data %- pairs:enjs ~ =/ ujon=(unit json) (de-json:html q.data.u.data) - ?~ ujon %- pairs ~ + ?~ ujon %- pairs:enjs ~ + ?> ?=(%o -.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 |= =inbound-request:eyre