/** * Instantiate a JsonLdService object */ public JsonLdServiceImpl() { options = new JsonLdOptions(); }
/** * Constructs an empty JsonLdApi object using the default JsonLdOptions, and * without initialization. */ public JsonLdApi() { this(new JsonLdOptions("")); }
/** * Constructs an empty JsonLdApi object using the default JsonLdOptions, and * without initialization. */ public JsonLdApi() { this(new JsonLdOptions("")); }
/** * Constructs an empty JsonLdApi object using the default JsonLdOptions, and * without initialization. */ public JsonLdApi() { this(new JsonLdOptions("")); }
/** * Outputs the RDF dataset found in the given JSON-LD object, using the * default {@link JsonLdOptions}. * * @param input * the JSON-LD input. * @return A JSON-LD object. * @throws JsonLdError * If there is an error converting the dataset to JSON-LD. */ public static Object toRDF(Object input) throws JsonLdError { return toRDF(input, new JsonLdOptions("")); }
/** * Outputs the RDF dataset found in the given JSON-LD object, using the * default {@link JsonLdOptions}. * * @param input * the JSON-LD input. * @return A JSON-LD object. * @throws JsonLdError * If there is an error converting the dataset to JSON-LD. */ public static Object toRDF(Object input) throws JsonLdError { return toRDF(input, new JsonLdOptions("")); }
public Context(Map<String, Object> map) { super(map); init(new JsonLdOptions()); }
/** * Outputs the RDF dataset found in the given JSON-LD object, using the * default {@link JsonLdOptions}. * * @param input * the JSON-LD input. * @return A JSON-LD object. * @throws JsonLdError * If there is an error converting the dataset to JSON-LD. */ public static Object toRDF(Object input) throws JsonLdError { return toRDF(input, new JsonLdOptions("")); }
/** * Expands the given input according to the steps in the <a * href="http://www.w3.org/TR/json-ld-api/#expansion-algorithm">Expansion * algorithm</a>, using the default {@link JsonLdOptions}. * * @param input * The input JSON-LD object. * @return The expanded JSON-LD document * @throws JsonLdError * If there is an error while expanding. */ public static List<Object> expand(Object input) throws JsonLdError { return expand(input, new JsonLdOptions("")); }
public Context(Map<String, Object> map) { super(map); init(new JsonLdOptions()); }
public String convertJSONLD(String json) throws IOException, JsonLdError { JsonLdOptions jsonLdOptions = new JsonLdOptions(); jsonLdOptions.format = "application/nquads"; Object jsonObject = JsonUtils.fromString(json); return JsonLdProcessor.toRDF(jsonObject, jsonLdOptions).toString(); }
static private JsonLdOptions defaultJsonLdOptions(String baseURI) { JsonLdOptions opts = new JsonLdOptions(baseURI); opts.useNamespaces = true ; // this is NOT jsonld-java's default // opts.setUseRdfType(true); // false -> use "@type" opts.setUseNativeTypes(true); // this is NOT jsonld-java's default opts.setCompactArrays(true); // this is jsonld-java's default return opts; }
@Activate protected void activate(ComponentContext ctx) { opts = new JsonLdOptions(); @SuppressWarnings("unchecked") Dictionary<String,Object> config = ctx.getProperties(); //boolean properties opts.setUseRdfType(getState(config.get(PROP_USE_RDF_TYPE), false)); opts.setUseNativeTypes(getState(config.get(PROP_USE_NATIVE_TYPES), false)); prettyPrint = getState(config.get(PROP_PRETTY_PRINT),true); //parse the string mode Object value = config.get(PROP_MODE); mode = value == null ? null : value.toString(); }
public void parse(final InputStream in, final String sourceURI) throws JsonLdError, IOException { _callback = new JsonLDtripleCallback(sourceURI); final JsonLdOptions options = new JsonLdOptions(sourceURI); JsonLdProcessor .toRDF(JsonUtils.fromInputStream(in), _callback, options); }
/** * Returns a new (mutable) JSON-LD options instance based on this context. */ public JsonLdOptions jsonLdOptions() { // TODO Technically both the documentLoader and potentially expandContext are mutable JsonLdOptions options = new JsonLdOptions(); options.setDocumentLoader(documentLoader); options.setBase(base); options.setExpandContext(expandContext); options.setOmitDefault(Boolean.TRUE); return options; }
@Test public void testFrame0001() throws IOException, JsonLdError { final Object frame = JsonUtils .fromInputStream(getClass().getResourceAsStream("/custom/frame-0001-frame.jsonld")); final Object in = JsonUtils .fromInputStream(getClass().getResourceAsStream("/custom/frame-0001-in.jsonld")); final Map<String, Object> frame2 = JsonLdProcessor.frame(in, frame, new JsonLdOptions()); assertEquals(2, frame2.size()); }
@Test public void testFrame0002() throws IOException, JsonLdError { final Object frame = JsonUtils .fromInputStream(getClass().getResourceAsStream("/custom/frame-0002-frame.jsonld")); final Object in = JsonUtils .fromInputStream(getClass().getResourceAsStream("/custom/frame-0002-in.jsonld")); final JsonLdOptions opts = new JsonLdOptions(); opts.setCompactArrays(false); final Map<String, Object> frame2 = JsonLdProcessor.frame(in, frame, opts); final Object out = JsonUtils .fromInputStream(getClass().getResourceAsStream("/custom/frame-0002-out.jsonld")); assertEquals(out, frame2); }
@Test public void testFrame0006() throws IOException, JsonLdError { final Object frame = JsonUtils .fromInputStream(getClass().getResourceAsStream("/custom/frame-0006-frame.jsonld")); final Object in = JsonUtils .fromInputStream(getClass().getResourceAsStream("/custom/frame-0006-in.jsonld")); final JsonLdOptions opts = new JsonLdOptions(); opts.setCompactArrays(true); final Map<String, Object> frame2 = JsonLdProcessor.frame(in, frame, opts); final Object out = JsonUtils .fromInputStream(getClass().getResourceAsStream("/custom/frame-0006-out.jsonld")); assertEquals(out, frame2); }
@Test public void testFrame0008() throws IOException, JsonLdError { final Object frame = JsonUtils .fromInputStream(getClass().getResourceAsStream("/custom/frame-0008-frame.jsonld")); final Object in = JsonUtils .fromInputStream(getClass().getResourceAsStream("/custom/frame-0008-in.jsonld")); final JsonLdOptions opts = new JsonLdOptions(); opts.setEmbed("@always"); final Map<String, Object> frame2 = JsonLdProcessor.frame(in, frame, opts); final Object out = JsonUtils .fromInputStream(getClass().getResourceAsStream("/custom/frame-0008-out.jsonld")); assertEquals(out, frame2); }
@Test public void testFrame0004() throws IOException, JsonLdError { final Object frame = JsonUtils .fromInputStream(getClass().getResourceAsStream("/custom/frame-0004-frame.jsonld")); final Object in = JsonUtils .fromInputStream(getClass().getResourceAsStream("/custom/frame-0004-in.jsonld")); final JsonLdOptions opts = new JsonLdOptions(); opts.setCompactArrays(true); final Map<String, Object> frame2 = JsonLdProcessor.frame(in, frame, opts); final Object out = JsonUtils .fromInputStream(getClass().getResourceAsStream("/custom/frame-0004-out.jsonld")); assertEquals(out, frame2); }