Parse a json string into a lossless R representation. Unlike jsonlite::fromJSON this does not try and deserialise the JSON into conventional R objects, but instead converts the data into a representation that can be inspected, modified and rewritten with to_json without any corruption caused by the ambiguity of R's lack of a true scalar type.

from_json(string)

Arguments

string

A string to parse as json

Value

An object of class tinyjson, which is our lossless representation of json data.

See also

from_json, which does the inverse transformation

Examples

tinyjson::from_json('[1, 2, 3, 4]')
#> $type
#> [1] "array"
#> 
#> $value
#> $value[[1]]
#> $value[[1]]$type
#> [1] "number"
#> 
#> $value[[1]]$value
#> [1] "1"
#> 
#> 
#> $value[[2]]
#> $value[[2]]$type
#> [1] "number"
#> 
#> $value[[2]]$value
#> [1] "2"
#> 
#> 
#> $value[[3]]
#> $value[[3]]$type
#> [1] "number"
#> 
#> $value[[3]]$value
#> [1] "3"
#> 
#> 
#> $value[[4]]
#> $value[[4]]$type
#> [1] "number"
#> 
#> $value[[4]]$value
#> [1] "4"
#> 
#> 
#> 
#> attr(,"class")
#> [1] "tinyjson"
tinyjson::from_json('{"a": "value"}')
#> $type
#> [1] "object"
#> 
#> $value
#> $value[[1]]
#> $value[[1]]$key
#> [1] "a"
#> 
#> $value[[1]]$value
#> $value[[1]]$value$type
#> [1] "string"
#> 
#> $value[[1]]$value$value
#> [1] "value"
#> 
#> 
#> 
#> 
#> attr(,"class")
#> [1] "tinyjson"