Examples of JsonLdOptions


Examples of com.github.jsonldjava.core.JsonLdOptions

        final Map<String, Object> ctx = new LinkedHashMap<String, Object>() ;
        addProperties(ctx, dataset.getDefaultGraph()) ;
        addPrefixes(ctx, prefixMap) ;

        try {
            JsonLdOptions opts = new JsonLdOptions(baseURI);
            opts.useNamespaces = true ;
            //opts.setUseRdfType(true);
            opts.setUseNativeTypes(true);
            opts.setCompactArrays(true);
            Object obj = JsonLdProcessor.fromRDF(dataset, opts, new JenaRDF2JSONLD()) ;
           
            Map<String, Object> localCtx = new HashMap<String, Object>() ;
            localCtx.put("@context", ctx) ;
View Full Code Here

Examples of com.github.jsonldjava.core.JsonLdOptions

        final Map<String, Object> ctx = new LinkedHashMap<>() ;
        addProperties(ctx, dataset.getDefaultGraph()) ;
        addPrefixes(ctx, prefixMap) ;

        try {
            JsonLdOptions opts = new JsonLdOptions(baseURI);
            opts.useNamespaces = true ;
            //opts.setUseRdfType(true);
            opts.setUseNativeTypes(true);
            opts.setCompactArrays(true);
            Object obj = JsonLdProcessor.fromRDF(dataset, opts, new JenaRDF2JSONLD()) ;
           
            Map<String, Object> localCtx = new HashMap<>() ;
            localCtx.put("@context", ctx) ;
View Full Code Here

Examples of com.github.jsonldjava.core.JsonLdOptions

        if (manifestURL.endsWith(".ttl") || manifestURL.endsWith("nq")
                || manifestURL.endsWith("nt")) {
            try {
                Map<String, Object> rval = (Map<String, Object>) JsonLdProcessor.fromRDF(
                        manifestFile, new JsonLdOptions(manifestURL) {
                            {
                                this.format = "text/turtle";
                                this.useNamespaces = true;
                                this.outputForm = "compacted";
                            }
                        });

                final Map<String, Object> frame = new LinkedHashMap<String, Object>();
                frame.put("@context", rval.get("@context"));
                frame.put("@type",
                        "http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#Manifest");
                // make manifest the base object, embeding any referenced items
                // (e.g. the test entries)
                rval = JsonLdProcessor.frame(rval, frame, new JsonLdOptions(manifestURL));
                // compact to remove the @graph label
                this.manifest = JsonLdProcessor.compact(rval, frame.get("@context"),
                        new JsonLdOptions(manifestURL));
                this.tests = (List<Map<String, Object>>) Obj.get(this.manifest, "mf:entries",
                        "@list");

            } catch (final JsonLdError e) {
                throw new RuntimeException(e);
View Full Code Here

Examples of com.github.jsonldjava.core.JsonLdOptions

        try {
            Object output = JsonLdProcessor.fromRDF(model, serialiser);

            final JSONLDMode mode = getWriterConfig().get(JSONLDSettings.JSONLD_MODE);

            final JsonLdOptions opts = new JsonLdOptions();
            // opts.addBlankNodeIDs =
            // getWriterConfig().get(BasicParserSettings.PRESERVE_BNODE_IDS);
            opts.setUseRdfType(getWriterConfig().get(JSONLDSettings.USE_RDF_TYPE));
            opts.setUseNativeTypes(getWriterConfig().get(JSONLDSettings.USE_NATIVE_TYPES));
            // opts.optimize = getWriterConfig().get(JSONLDSettings.OPTIMIZE);

            if (mode == JSONLDMode.EXPAND) {
                output = JsonLdProcessor.expand(output, opts);
            }
View Full Code Here

Examples of com.github.jsonldjava.core.JsonLdOptions

    public void parse(final InputStream in, final String baseURI) throws IOException,
            RDFParseException, RDFHandlerException {
        final SesameTripleCallback callback = new SesameTripleCallback(getRDFHandler(),
                valueFactory, getParserConfig(), getParseErrorListener());

        final JsonLdOptions options = new JsonLdOptions(baseURI);
        options.useNamespaces = true;

        try {
            JsonLdProcessor.toRDF(JsonUtils.fromInputStream(in), callback, options);
        } catch (final JsonLdError e) {
View Full Code Here

Examples of com.github.jsonldjava.core.JsonLdOptions

    public void parse(final Reader reader, final String baseURI) throws IOException,
            RDFParseException, RDFHandlerException {
        final SesameTripleCallback callback = new SesameTripleCallback(getRDFHandler(),
                valueFactory, getParserConfig(), getParseErrorListener());

        final JsonLdOptions options = new JsonLdOptions(baseURI);
        options.useNamespaces = true;

        try {
            JsonLdProcessor.toRDF(JsonUtils.fromReader(reader), callback, options);
        } catch (final JsonLdError e) {
View Full Code Here

Examples of com.github.jsonldjava.core.JsonLdOptions

        try {
            if (args.length < 2 || !args[0].startsWith("--")) {
                usage();
            } else {

                final JsonLdOptions opts = new JsonLdOptions("");
                Object inobj = null;
                Object ctxobj = null;
                String opt = null;
                for (int i = 0; i < args.length;) {
                    if ("--debug".equals(args[i])) {
                        i++;
                        debug = true;
                    } else if ("--base".equals(args[i])) {
                        i++;
                        opts.setBase(args[i++]);
                    } else if ("--outputForm".equals(args[i])) {
                        i++;
                        opts.outputForm = args[i++];
                    } else if (validOption(args[i])) {
                        if (opt != null) {
                            System.out
                                    .println("Error: can only do one operation on the input at a time");
                            usage();
                            return;
                        }
                        opt = args[i];
                        i++;
                        if (args.length <= i) {
                            System.out.println("Error: missing file names after argument "
                                    + args[i - 1]);
                            usage();
                            return;
                        }
                        File in = new File(args[i++]);
                        if (!in.exists()) {
                            System.out.println("Error: file \"" + args[i - 1] + "\" doesn't exist");
                            usage();
                            return;
                        }
                        // if base is currently null, set it
                        if (opts.getBase() == null || opts.getBase().equals("")) {
                            opts.setBase(in.toURI().toASCIIString());
                        }
                        if ("--fromRDF".equals(opt)) {
                            final BufferedReader buf = new BufferedReader(new InputStreamReader(
                                    new FileInputStream(in), "UTF-8"));
                            inobj = "";
View Full Code Here

Examples of com.github.jsonldjava.core.JsonLdOptions

        try {
            Object output = JsonLdProcessor.fromRDF(model, serialiser);

            final JSONLDMode mode = getWriterConfig().get(JSONLDSettings.JSONLD_MODE);

            final JsonLdOptions opts = new JsonLdOptions();
            // opts.addBlankNodeIDs =
            // getWriterConfig().get(BasicParserSettings.PRESERVE_BNODE_IDS);
            opts.setUseRdfType(getWriterConfig().get(JSONLDSettings.USE_RDF_TYPE));
            opts.setUseNativeTypes(getWriterConfig().get(JSONLDSettings.USE_NATIVE_TYPES));
            // opts.optimize = getWriterConfig().get(JSONLDSettings.OPTIMIZE);

            if (mode == JSONLDMode.EXPAND) {
                output = JsonLdProcessor.expand(output, opts);
            }
View Full Code Here

Examples of com.github.jsonldjava.core.JsonLdOptions

        final Map<String, Object> ctx = new LinkedHashMap<String, Object>();
        addProperties(ctx, dataset.getDefaultGraph());
        addPrefixes(ctx, prefixMap);

        try {
            final JsonLdOptions opts = new JsonLdOptions(baseURI);
            // opts.graph = false;
            // opts.addBlankNodeIDs = false;
            opts.setUseRdfType(true);
            opts.setUseNativeTypes(true);
            // opts.skipExpansion = false;
            opts.setCompactArrays(true);
            // opts.keepFreeFloatingNodes = false;
            final JsonLdApi api = new JsonLdApi(opts);
            final JenaRDFParser parser = new JenaRDFParser();
            final RDFDataset result = parser.parse(dataset);
            Object obj = api.fromRDF(result);
View Full Code Here

Examples of com.github.jsonldjava.core.JsonLdOptions

        final Model model = ModelFactory.createDefaultModel();
        final Resource resource = model.createResource("http://example.com/test");
        final Property property = model.createProperty("http://example.com/value");
        model.add(resource, property, "Test");

        final JsonLdOptions options = new JsonLdOptions();
        options.format = "application/ld+json";
        final JenaRDFParser parser = new JenaRDFParser();
        final RDFDataset dataset = parser.parse(model);
        final Object json = new JsonLdApi(options).fromRDF(dataset);
        final String jsonStr = JSONUtils.toPrettyString(json);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.