Skip to content

Commit

Permalink
Fix JSON parsing for example hn.nim.
Browse files Browse the repository at this point in the history
  • Loading branch information
treeform committed Dec 5, 2020
1 parent b6e0261 commit e67ff45
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions examples/hn/hn.nim
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ proc news(id: string) =
box 389, 0, 96, 18
fill "#000000", 0.5
font "IBM Plex Sans", 14, 400, 0, hLeft, vTop
let uri = parseUri(call.json["url"].getStr())
characters "(" & uri.hostname & ")"
if "url" in call.json:
let uri = parseUri(call.json["url"].getStr())
characters "(" & uri.hostname & ")"
textAutoResize tsWidthAndHeight
layoutAlign laCenter
text "title":
Expand Down Expand Up @@ -77,7 +78,8 @@ proc news(id: string) =
box 305, 0, 87, 18
fill "#000000", 0.5
font "IBM Plex Sans", 14, 400, 0, hLeft, vTop
characters $call.json["descendants"].getInt() & " comments"
if "descendants" in call.json:
characters $call.json["descendants"].getInt() & " comments"
textAutoResize tsWidthAndHeight
layoutAlign laCenter
text "bar":
Expand Down

0 comments on commit e67ff45

Please sign in to comment.