我正在构建一个Android JSON应用编程接口,我使用的是application.The -LD格式的数据。我以前从未使用过JSON-LD,因此不确定如何解析这些数据。我试过用谷歌搜索,但Android和JSON-LD似乎都有0个结果,只有JSON。
我不确定如何在我的应用程序中使用此API
请帮帮忙
发布于 2015-08-18 21:52:01
你看过这个了吗-- https://github.com/jsonld-java/jsonld-java
下面是一个示例代码
// Open a valid json(-ld) input file
InputStream inputStream = new FileInputStream("input.json");
// Read the file into an Object (The type of this object will be a List, Map, String, Boolean,
// Number or null depending on the root object in the file).
Object jsonObject = JsonUtils.fromInputStream(inputStream);
// Create a context JSON map containing prefixes and definitions
Map context = new HashMap();
// Customise context...
// Create an instance of JsonLdOptions with the standard JSON-LD options
JsonLdOptions options = new JsonLdOptions();
// Customise options...
// Call whichever JSONLD function you want! (e.g. compact)
Object compact = JsonLdProcessor.compact(jsonObject, context, options);
// Print out the result (or don't, it's your call!)
System.out.println(JsonUtils.toPrettyString(compact));https://stackoverflow.com/questions/32074180
复制相似问题