문제

suppose I have this list in R

x = list(a=1:3,b=8:20)

and I write this to a json file on disk with

library(jsonlite)
cat(toJSON(x),file="f.json")

how can I use the Julia JSON package to read that? Can I?

# Julia
using JSON
JSON.parse("/Users/florianoswald/f.json")

gives a mistake - I guess it expects a json string.

Any alternatives? I would benefit from being able to pass a list (i.e. a nested structure) rather than tabular data. thanks!

도움이 되었습니까?

해결책

If you want to do this with the current version of JSON you can use Julia's readall method to get a string from a file.

Pkg.clone("JSON") will get you the latest development version of JSON.jl (as opposed to the latest released version) – it seems parsefile is not released yet.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top