Examples of JsonLdOptions


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 JsonLdApi api = new JsonLdApi(options);
        final RDFDataset dataset = new RDFDataset(api);
        final Object json = api.fromRDF(dataset);
        final String jsonStr = JSONUtils.toPrettyString(json);
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 {
            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
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.