Closed marcelovilla closed 3 years ago
Even replacing the URL it gets an error, I used the next code to run the code:
jsonWords = "{\"words\" : [\"heaven\",\"hell\",\"man\",\"woman\",\"boy\",\"girl\", \"king\",\"queen\",\"prince\",\"sir\",\"love\",\"hate\", \"knife\",\"english\",\"england\",\"god\"], \"numToShow\" : 5}"
The URL works for me:
jsonUrl = "https://raw.githubusercontent.com/h-Klok/StatsWithJuliaBook/master/data/jsonCode.json"
jsonWords = HTTP.request("GET", jsonUrl)
parsedJsonDict = JSON.parse(String(jsonWords.body))
The code gets an error when it is used in Atom, that's why I created "jsonWords":
MethodError: no method matching parse(::HTTP.Messages.Response) Closest candidates are: parse(!Matched::AbstractString; dicttype, inttype, allownan, null) at C:\Users\USER.juliapro\JuliaPro_v1.4.2-1\packages\JSON\d89fA\src\Parser.jl:461 parse(!Matched::IO; dicttype, inttype, allownan, null) at C:\Users\USER.juliapro\JuliaPro_v1.4.2-1\packages\JSON\d89fA\src\Parser.jl:492 top-level scope at Statistics_with_Julia.jl:170
Are you importing the modules with using HTTP, JSON
on top of your file?
Yes, I was:
using HTTP, JSON
data = HTTP.request("GET", "https://ocw.mit.edu/ans7870/6/6.006/s08/lecturenotes/files/t8.shakespeare.txt") shakespeare = String(data.body) shakespeareWords = split(shakespeare)
Thank you very much. Good catch. We fixed this.
The URL for the jsonCode.json file in the draft is: https://raw.githubusercontent.com/h-Klok/StatsWithJuliaBook/master/1_chapter/jsonCode.json However, the correct URL is: https://raw.githubusercontent.com/h-Klok/StatsWithJuliaBook/master/data/jsonCode.json