我正在尝试将 json 转换为 json-ld。到目前为止,我已经尝试过来自 nuget 的 json-ld.net 库(它是 nuget3 的一部分):https ://www.nuget.org/packages/json-ld.net/
var jtoken = JsonLD.Util.JSONUtils.FromString(response);
var options = new JsonLdOptions();
options.SetBase("http://json-ld.org/test-suite/tests/");
options.SetProduceGeneralizedRdf(true);
var context = JsonLD.Util.JSONUtils.FromString(Properties.Resources.jasonldcontext);
options.SetExpandContext((JObject)context);
var jtokenout = JsonLdProcessor.Compact(jtoken, context, options);
var sz = JSONUtils.ToString(jtokenout);
Run Code Online (Sandbox Code Playgroud)
上下文资源:
{"@context": {
"ex": "http://example.org/",
"term1": {"@id": "ex:term1", "@type": "ex:datatype"},
"term2": {"@id": "ex:term2", "@type": "@id"}
}}
Run Code Online (Sandbox Code Playgroud)
我的 json 存在且有效。它来自 REST 服务。(响应),并填充 jtoken。但是, sz 仅包含上下文:
context":{"ex":"http://example.org/","term1":
{"@id":"ex:term1","@type":"ex:datatype"},"term2":
{"@id":"ex:term2","@type":"@id"}}}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4114 次 |
| 最近记录: |