سؤال

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