首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >解析Android中的JSON-LD

解析Android中的JSON-LD
EN

Stack Overflow用户
提问于 2015-08-18 21:43:52
回答 1查看 1.2K关注 0票数 3

我正在构建一个Android JSON应用编程接口,我使用的是application.The -LD格式的数据。我以前从未使用过JSON-LD,因此不确定如何解析这些数据。我试过用谷歌搜索,但Android和JSON-LD似乎都有0个结果,只有JSON。

我不确定如何在我的应用程序中使用此API

请帮帮忙

EN

回答 1

Stack Overflow用户

发布于 2015-08-18 21:52:01

你看过这个了吗-- https://github.com/jsonld-java/jsonld-java

下面是一个示例代码

代码语言:javascript
运行
复制
// 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));
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32074180

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档