COMING SOON: JSON parser for N:
Verfasst: 15.05.2022 21:45
Hello everyone,
A year ago, I had to rewrite the network code. It meant that the JSON parser that I had originally written, was taken out, until I could replace it.
I have now done the first pass of the JSON parser, which allows one to:
* Open a connection to some JSON data, e.g. (N:HTTPS://oldbytes.space/api/v1/timelines/public?limit=1)
* Set the channel mode to JSON (XIO 252,#1,12,1,"N:")
* Tell the JSON parser to parse that information (XIO ASC("P),#1,12,0,"N:")
And from this point, the JSON document is parsed in the FujiNet, and can be queried for any pieces of information you wish to retrieve, e.g.
And it will be returned via the I/O channel, ready to be picked up with a CIO GET CHARACTER or GET RECORD call e.g.
The current JSON parser will parse all of the JSON primitives.
An example of this, is the world's simplest Mastodon client, written in ATARI BASIC, which displays the newest public post:
Yes, really, that's it.
And you get something like this:
It will be in the next released build for both Atari and Coleco Adam, which will be released very soon.
-Thom
A year ago, I had to rewrite the network code. It meant that the JSON parser that I had originally written, was taken out, until I could replace it.
I have now done the first pass of the JSON parser, which allows one to:
* Open a connection to some JSON data, e.g. (N:HTTPS://oldbytes.space/api/v1/timelines/public?limit=1)
* Set the channel mode to JSON (XIO 252,#1,12,1,"N:")
* Tell the JSON parser to parse that information (XIO ASC("P),#1,12,0,"N:")
And from this point, the JSON document is parsed in the FujiNet, and can be queried for any pieces of information you wish to retrieve, e.g.
Code: Alles auswählen
XIO ASC("Q"),#1,12,0,"N:/0/account/display_name"
Code: Alles auswählen
INPUT #1,NAME$
An example of this, is the world's simplest Mastodon client, written in ATARI BASIC, which displays the newest public post:
Code: Alles auswählen
0 DIM A$(256)
10 OPEN #1,12,0,"N:HTTPS://oldbytes.space/api/v1/timelines/public?limit=1"
11 TRAP 91
20 XIO 252,#1,12,1,"N:":REM SET CHANNEL MODE
30 XIO ASC("P"),#1,12,0,"N:":REM PARSE JSON
40 XIO ASC("Q"),#1,12,0,"N:/0/created_at"
50 INPUT #1,A$:? A$
60 XIO ASC("Q"),#1,12,0,"N:/0/account/display_name"
70 INPUT #!,A$:? A$
80 XIO ASC("Q"),#1,12,0,"N:/0/content/"
90 GET #1,A:? CHR$(A);:GOTO 90
91 CLOSE #1:END
And you get something like this:
It will be in the next released build for both Atari and Coleco Adam, which will be released very soon.
-Thom