< Summary

Information
Class: src/jsonpointer.jl
Assembly: Default
File(s): src/jsonpointer.jl
Tag: 40_3060321334
Line coverage
71%
Covered lines: 42
Uncovered lines: 17
Coverable lines: 59
Total lines: 88
Line coverage: 71.1%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Method coverage is only available for sponsors.

Upgrade to PRO version

File(s)

src/jsonpointer.jl

#LineLine coverage
 1
 2"""
 3_column_to_pointer{T}(p::Pointer)
 4
 5construct JSONPointer.Pointer with specified type
 6"""
 2327function _column_to_pointer(token_string::AbstractString)::Pointer
 2328    if !startswith(token_string, JSONPointer.TOKEN_PREFIX)
 169        token_string = "/" * token_string
 10    end
 23211    if endswith(token_string, "}")
 2412        x = split(token_string, "{")
 2413        p = Pointer(x[1])
 2414        T = jsontype_to_juliatype(x[2][1:end-1])
 15
 2416        return Pointer{Array{T, 1}}(p.tokens)
 17    else
 20818        return Pointer(token_string)
 19    end
 20end
 021_column_to_pointer(token) = _column_to_pointer(string(token))
 22
 2423function jsontype_to_juliatype(t)
 3424    if t == "string"
 525        return String
 2926    elseif t == "number"
 927        return Float64
 28    # JSON does not have distinct types for integers and floating-point values
 29    # but Excel does, and distinguishing integer is useful for many things.
 1030    elseif t == "integer"
 1031        return Int
 032    elseif t == "object"
 033        return OrderedDict{String,Any}
 034    elseif t == "array"
 035        return Vector{Any}
 036    elseif t == "boolean"
 037        return Bool
 038    elseif t == "null"
 039        return Missing
 40    else
 041        error(
 42            "You specified a type that JSON doesn't recognize! Instead of " *
 43            "`::$t`, you must use one of `::string`, `::number`, " *
 44            "`::object`, `::array`, `::boolean`, or `::null`."
 45        )
 46    end
 47end
 48
 3249function pointer_to_colname(p::Pointer{T})::String where T
 3250    col = "/" * join(p.tokens, "/")
 3251    t = juliatype_to_jsontype(T)
 3252    if t == "array"
 453        col *= "::$t"
 454        t2 = juliatype_to_jsontype(eltype(T))
 455        if !isempty(t2)
 356            col *= "{$t2}"
 57        end
 2858    elseif !isempty(t)
 059        col *= "::$t"
 60    end
 3261    return col
 62end
 63
 3664function juliatype_to_jsontype(T)
 3665    if T <: OrderedDict
 066        t = "object"
 3667    elseif T <: Array
 468        t = "array"
 3269    elseif T == String
 170        t = "string"
 3171    elseif T == Float64
 172        t = "number"
 3073    elseif T == Int
 174        t = "integer"
 2975    elseif T == Bool
 076        t = "boolean"
 2977    elseif T == Missing
 078        t = "null"
 2979    elseif T == Nothing
 080        t = "null"
 2981    elseif T == Any
 2982        t = ""
 83    else
 084        @warn("cannot find jsontype from $T, returning empty string")
 085        t = ""
 86    end
 3687    return t
 88end

Methods/Properties