Page 1 of 1

json-parse string expected

Posted: Sun May 06, 2018 9:49 am
by joejoe
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!

Re: json-parse string expected

Posted: Sun May 06, 2018 5:48 pm
by TedWalther
Are you sure the link is spelled correctly? When I click the link, I get "page not found".

Re: json-parse string expected

Posted: Mon May 07, 2018 1:15 am
by joejoe
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")))