Parsing breaks on JSON-LD 1.1 `@version` keyword. · Issue #263 · jsonld-java/jsonld-java · GitHub
Skip to content

Parsing breaks on JSON-LD 1.1 @version keyword. #263

Description

@RinkeHoekstra

The graphToRdf function in RDFDataset.java checks whether any of the keys in the JSON document are reserved JSON-LD keywords. As JsonLdUtils.isKeyword() doesn't know of @version (introduced in 1.1), it then tries to interpret its value, which fails.

Solution: add || "@version".equals(key) to the isKeyword function in JsonLdUtils.java:

    /**
     * Returns whether or not the given value is a keyword (or a keyword alias).
     *
     * @param v
     *            the value to check.
     * @param [ctx]
     *            the active context to check against.
     *
     * @return true if the value is a keyword, false if not.
     */
    static boolean isKeyword(Object key) {
        if (!isString(key)) {
            return false;
        }
        return "@base".equals(key) || "@context".equals(key) || "@container".equals(key)
                || "@default".equals(key) || "@embed".equals(key) || "@explicit".equals(key)
                || "@graph".equals(key) || "@id".equals(key) || "@index".equals(key)
                || "@language".equals(key) || "@list".equals(key) || "@omitDefault".equals(key)
                || "@reverse".equals(key) || "@preserve".equals(key) || "@set".equals(key)
                || "@type".equals(key) || "@value".equals(key) || "@vocab".equals(key)
                || "@requireAll".equals(key) || "@version".equals(key);
    }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions