Hi Sandy,
On 07.09.2023 17:39, Sanford Geiger wrote:
*Is there an ooRexx example of using rexxcurl with the JSON class? *
As the command curl is now available on Windows as well (it has been available on the Unix operating
systems for a long while), here a program that uses the curl command and processes the json string
that gets returned:
/*
Cf. slides:
-https://wi.wu.ac.at/rgf/wu/lehre/autojava/material/foils/060_ooRexx_commands_V14.pdf
(also see link section at the very end)
-https://wi.wu.ac.at/rgf/wu/lehre/autojava/material/foils/340_JSON_V03.pdf
*/
cmd="curl --silent --location" '"https://swapi.dev/api/"'
say "cmd:" pp(cmd)
say
arrOut=.array~new
address system cmd with output using (arrOut)
say "received:" pp(arrOut)
say "---"
j=.json~new -- create instance
d=j~fromJson(arrOut~makeString) -- use it to turn JSON text into a directory
say "d:" d "d~items:" d~items
say "listing entries:"
do counter c idx over d~allIndexes~sort
say c~right(3)": idx="left(pp(idx),15,".") pp(d[idx])
end
::requires "json.cls" -- get JSON support
::routine pp
return "["arg(1)"]"
Here the output:
G:\tmp\orx\curl>test.rex
cmd: [curl --silent --location"https://swapi.dev/api/"]
received:
[{"people":"https://swapi.dev/api/people/","planets":"https://swapi.dev/api/planets/","films":"https://swapi.dev/api/films/","species":"https://swapi.dev/api/species/","vehicles":"https://swapi.dev/api/vehicles/","starships":"https://swapi.dev/api/starships/"}]
---
d: a Directory d~items: 6
listing entries:
1: idx=[films]........ [https://swapi.dev/api/films/]
2: idx=[people]....... [https://swapi.dev/api/people/]
3: idx=[planets]...... [https://swapi.dev/api/planets/]
4: idx=[species]...... [https://swapi.dev/api/species/]
5: idx=[starships].... [https://swapi.dev/api/starships/]
6: idx=[vehicles]..... [https://swapi.dev/api/vehicles/]
HTH,
---rony
**
*
*
*From:* Sahananda Sahananda <sahana...@gmail.com>
*Sent:* Thursday, September 7, 2023 10:39 AM
*To:* Open Object Rexx Developer Mailing List
<oorexx-devel@lists.sourceforge.net>
*Subject:* Re: [Oorexx-devel] ooRexx access to Google Sheets
Looking at https://developers.google.com/sheets/api/guides/concepts
It appears Google sheets has a restful api. You can usually access a restful api using curl or
rexx/curl and the Json class. Have a poke around the documentation and if you give it a try and
need help, ask back here.
Jon
On Thu, 7 Sep 2023, 03:31 Sanford Geiger, <sanford.gei...@live.com> wrote:
Is there a way to directly access Google Sheets using
ooRexx? If so, how?
Thank you,
Sandy Geiger
_______________________________________________
Oorexx-devel mailing list
Oorexx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/oorexx-devel