android - 在 Android 中解析 JSON-LD

标签 android json api parsing json-ld

我正在构建一个 Android 应用程序。我正在使用的 API 以 JSON-LD 格式提供数据。我之前从未使用过 JSON-LD,因此我不确定如何解析这些数据。我试过谷歌搜索,但似乎有 0 个结果结合了 Android 和 JSON-LD,只有 JSON。

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

请帮忙

最佳答案

你检查过了吗 - 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));

关于android - 在 Android 中解析 JSON-LD,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32074180/

相关文章:

android - RuleBasedCollat​​or 不适用于 Android?

jquery - 为什么我的标签内容不刷新?

arrays - 如何使用 node.js 将多个 json 对象合并到一个 json 文件中

javascript - JSON 未定义,Chrome

c++ - "Everything Search"究竟如何能在不到 10 秒的时间内为我提供 4TB 硬盘上 20 亿个文件的可立即搜索列表?

android - 如何解决路径中的异常非法字符?

java - Android 捕获 LinearLayout 上的触摸 : Cannot Resolve Symbol setOnTouchListener.

android - 在选定的 ListView 上设置背景?

javascript - 通过 JavaScript SDK 进行 API 身份验证

python - 如何修改 django-rest-framework API