I have a json file with measurement types- any idea how to read it back to julia?
ie: file looks like
S.json={
"D":4.0 ± 0.2,
"tspan":{"t0":0,"tf":100},
"params":{
"p":20.0 ± 4.0,
"c":0.2 ± 0.04000000000000001
}
}
using Json
function processInputs(inputdata)
println("Getting Input Parameters.")
open(inputdata, "r") do g
global allParams
allParams=JSON.parse(g,inttype=Float64) # parse and transform data
end
return allParams
end
allparams=processInputs("S.json")
result in:
Getting Input Parameters.
Expected ‘,’ here
…when parsing byte with value ‘194’
error(::String) at ./error.jl:33
_error(::String, ::JSON.Parser.StreamingParserState{IOStream}) at /opt/julia/packages/JSON/ebvl3/src/Parser.jl:150
_error_expected_char(::UInt8, ::JSON.Parser.StreamingParserState{IOStream}) at /opt/julia/packages/JSON/ebvl3/src/Parser.jl:85
skip! at /opt/julia/packages/JSON/ebvl3/src/Parser.jl:82 [inlined]
parse_object(::JSON.Parser.ParserContext{Dict{String,Any},Float64}, ::JSON.Parser.StreamingParserState{IOStream}) at /opt/julia/packages/JSON/ebvl3/src/Parser.jl:229
parse_value(::JSON.Parser.ParserContext{Dict{String,Any},Float64}, ::JSON.Parser.StreamingParserState{IOStream}) at /opt/julia/packages/JSON/ebvl3/src/Parser.jl:168
#parse#2(::Type, ::Type{Float64}, ::Function, ::IOStream) at /opt/julia/packages/JSON/ebvl3/src/Parser.jl:427
(::getfield(JSON.Parser, Symbol(“#kw##parse”)))(::NamedTuple{(:inttype,),Tuple{DataType}}, ::typeof(JSON.Parser.parse), ::IOStream) at ./none:0
#50 at ./In[20]:5 [inlined]
#open#294(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::getfield(Main, Symbol(“##50#51”)), ::String, ::Vararg{String,N} where N) at ./iostream.jl:369
open at ./iostream.jl:367 [inlined]
processInputs(::String) at ./In[20]:3
top-level scope at none:0
eval at ./boot.jl:319 [inlined]
(::getfield(Distributed, Symbol(“##164#166”)){Module,Expr})() at ./task.jl:259
Stacktrace:
[1] sync_end(::Array{Any,1}) at ./task.jl:226
[2] remotecall_eval(::Module, ::Array{Int64,1}, ::Expr) at /opt/julia-1.0.0/share/julia/stdlib/v1.0/Distributed/src/macros.jl:207