| | | 1 | | |
| | | 2 | | """ |
| | | 3 | | _column_to_pointer{T}(p::Pointer) |
| | | 4 | | |
| | | 5 | | construct JSONPointer.Pointer with specified type |
| | | 6 | | """ |
| | | 7 | | function _column_to_pointer(token_string::AbstractString)::Pointer |
| | 460 | 8 | | if !startswith(token_string, JSONPointer.TOKEN_PREFIX) |
| | 15 | 9 | | token_string = "/" * token_string |
| | | 10 | | end |
| | 230 | 11 | | if endswith(token_string, "}") |
| | 18 | 12 | | x = split(token_string, "{") |
| | 18 | 13 | | p = Pointer(x[1]) |
| | 18 | 14 | | T = jsontype_to_juliatype(x[2][1:end-1]) |
| | | 15 | | |
| | 18 | 16 | | return Pointer{Array{T, 1}}(p.tokens) |
| | | 17 | | else |
| | 212 | 18 | | return Pointer(token_string) |
| | | 19 | | end |
| | | 20 | | end |
| | | 21 | | |
| | | 22 | | function jsontype_to_juliatype(t) |
| | 18 | 23 | | if t == "string" |
| | 3 | 24 | | return String |
| | 15 | 25 | | elseif t == "number" |
| | 7 | 26 | | return Float64 |
| | | 27 | | # JSON does not have distinct types for integers and floating-point values |
| | | 28 | | # but Excel does, and distinguishing integer is useful for many things. |
| | 8 | 29 | | elseif t == "integer" |
| | 8 | 30 | | return Int |
| | 0 | 31 | | elseif t == "object" |
| | 0 | 32 | | return OrderedCollections.OrderedDict{String,Any} |
| | 0 | 33 | | elseif t == "array" |
| | 0 | 34 | | return Vector{Any} |
| | 0 | 35 | | elseif t == "boolean" |
| | 0 | 36 | | return Bool |
| | 0 | 37 | | elseif t == "null" |
| | 0 | 38 | | return Missing |
| | | 39 | | else |
| | 0 | 40 | | error( |
| | | 41 | | "You specified a type that JSON doesn't recognize! Instead of " * |
| | | 42 | | "`::$t`, you must use one of `::string`, `::number`, " * |
| | | 43 | | "`::object`, `::array`, `::boolean`, or `::null`." |
| | | 44 | | ) |
| | | 45 | | end |
| | | 46 | | end |