- From: emri mbiemri <emrimbiemri8080@gmail.com>
- Date: Tue, 21 Dec 2021 19:05:15 +0200
- To: public-json-ld-wg@w3.org
- Message-ID: <CAKQKL02yJ3Gr0gSbJ7yzoSNjV0+G8Q5ZTWQVh_VCX+Wrpq8Teg@mail.gmail.com>
I am trying to convert JSON to RDF graphs. For this, I have to initially
convert JSON to JSONLD. I am trying to do this by using JSONLD-JAVA
<https://github.com/jsonld-java/jsonld-java>. The problem is that I get
only empty object as result. I know that I can add a @context annotation
manually for small and simple JSON models, which works for very simple JSON
files, but I have to work with quite big JSON models like this
<https://github.com/iliriani/iliriangit/blob/master/CustomerForm.form%20(1).xml>
which
can not be converted only by adding a context.
Here is my java code:
String file = "C:\\Users\\Admin\\Desktop\\Forms\\test\\stack.json";
// Open a valid json(-ld) input file
InputStream inputStream = new FileInputStream(file);
Object jsonObject = JsonUtils.fromInputStream(inputStream);
// Create a context JSON map containing prefixes and definitions
Map context = new HashMap();
System.out.println(jsonObject);
// Create an instance of JsonLdOptions with the standard JSON-LD options
JsonLdOptions options = new JsonLdOptions();
//Convert to JSONLD
Object compact = JsonLdProcessor.compact(jsonObject, context,
options);// System.out.println("Compact is: "+compact);//
Object compact = JsonLdProcessor.compact(jsonObject, new HashMap<>(),
new JsonLdOptions());
// Print out the result (or don't, it's your call!)
System.out.println(JsonUtils.toPrettyString(compact));}
-------------------------
Hope for any help to convert JSON to JSONLD from your side. Thanks a lot.
Received on Wednesday, 22 December 2021 09:15:09 UTC