json-parse string expected

Q&A's, tips, howto's

json-parse string expected

Postby joejoe » Sun May 06, 2018 9:49 am

Hi,

(json-parse (exec "curl https://www.asdf.com/asdf.json"))

I am getting the message that a string is expected.

The result of the exec has [text]......[/text] at the beginning and end of what is returned.

Is this why json-parse thinks it is not a string?

I tried (json-parse (string (exec "curl....))) too. Still says a string is expected.

How do I remove the [text] ... [/text] so that the result can be interpreted by (json-parse)?

Thanks!
joejoe
 
Posts: 140
Joined: Thu Jun 25, 2009 5:09 pm

Re: json-parse string expected

Postby TedWalther » Sun May 06, 2018 5:48 pm

Are you sure the link is spelled correctly? When I click the link, I get "page not found".
Cavemen in bearskins invaded the ivory towers of Artificial Intelligence. Nine months later, they left with a baby named newLISP. The women of the ivory towers wept and wailed. "Abomination!" they cried.
TedWalther
 
Posts: 590
Joined: Mon Feb 05, 2007 1:04 am
Location: Abbotsford, BC

Re: json-parse string expected

Postby joejoe » Mon May 07, 2018 1:15 am

Thanks again Ted,! I was able to do it with get-url here.

Code: Select all
(json-parse (get-url "https://pastebin.com/raw/brx7F2vA"))


Code: Select all
(("ID" ("1" "2" "3" "4" "5" "6" "7" "8")) ("Name" ("Rick" "Dan" "Michelle" "Ryan"             
   "Gary" "Nina" "Simon" "Guru"))                                                             
 ("Salary" ("623.3" "515.2" "611" "729" "843.25" "578" "632.8" "722.5"))                     
 ("StartDate" ("1/1/2012" "9/23/2013" "11/15/2014" "5/11/2014" "3/27/2015" "5/21/2013"       
   "7/30/2013" "6/17/2014"))
 ("Dept" ("IT" "Operations" "IT" "HR" "Finance" "IT" "Operations" "Finance")))
joejoe
 
Posts: 140
Joined: Thu Jun 25, 2009 5:09 pm


Return to newLISP in the real world

Who is online

Users browsing this forum: No registered users and 0 guests