user120911
user120911

Reputation: 285

Using Julia to open a JSON file that is located at a particular directory

Suppose there is a JSON file at a particular location. Let's say at "C:\Data\". Using Julia, how do I load the file, so that I may use its content for analysis?

The following link provides access to a sample of my JSON files. For the readers information, I am in the process of learning how to extract market data from Betfair.

Link: Betfair JSON File Example

Upvotes: 9

Views: 7147

Answers (1)

fredrikekre
fredrikekre

Reputation: 10984

You just specify the full path to the file to the JSON parser you are working with. For example with the JSON package:

julia> using JSON

julia> JSON.parsefile("/Users/fredrik/test.json") # full path
Dict{String,Any} with 2 entries:
  "hello" => 1
  "world" => Any[1, 2]

If you are running the code in the same directory as the JSON file you can just use the filename since Julia defaults to look in the current directory:

julia> JSON.parsefile("test.json") # relative path
Dict{String,Any} with 2 entries:
  "hello" => 1
  "world" => Any[1, 2]

Upvotes: 11

Related Questions