如何解决如何使用 JSON-LD 帧过滤 JSON-LD 对象数组?
我花了两天时间尝试执行以下操作,但没有成功。
我有这个示例 JSON-LD 文档:
{
"@context": [
"https://www.w3.org/2018/credentials/v1","https://w3c-ccg.github.io/ldp-bbs2020/context/v1","https://mycontext.com/credentials/v1"
],"type": ["VerifiableCredential"],"issuer": "did:example:issuer","issuanceDate": "2020-01-01T00:00:00Z","expirationDate": "2029-12-31T23:59:59Z","credentialSubject": {
"id": "did:example:subject","type": ["ExampleCredential"],"values": [
{
"a": 1,"b": 2,"c": 3
},{
"a": 4,"b": 5,"c": 6
}
]
}
}
以及以下 JSON-LD 上下文(假设可在 https://mycontext.com/credentials/v1 处检索):
{
"@context": {
"@version": 1.1,"@protected": true,"schema": "https://schema.org/","ExampleCredential": {
"@id": "https://mycontext.com/credentials#ExampleCredential","@context": {
"@version": 1.1,"type": "@type","values": "@nest","a": {
"@id": "https://mycontext.com/credentials#a","@type": "schema:example_a","@nest": "values"
},"b": {
"@id": "https://mycontext.com/credentials#b","@type": "schema:example_b","c": {
"@id": "https://mycontext.com/credentials#c","@type": "schema:example_c","@nest": "values"
}
}
}
}
}
此外,我尝试使用以下 JSON-LD 框架仅过滤凭证中字段 a
等于 1
的元素:
{
"@context": [
"https://www.w3.org/2018/credentials/v1","@explicit": true,"issuanceDate": {},"expirationDate": {},"b": {},"c": {}
}
]
}
}
我正在使用 jsonld package 来执行这些操作,我想得到的最终结果对应于初始文档,但是 values
字段被过滤为仅包含其中的第一个对象列表。这只是最后一次尝试,我已经尝试了从 "@container": "@set"
到 @nest
的所有内容,但显然我遗漏了一些东西。格式化上下文和/或框架以便达到预期结果的正确方法是什么?也就是,在孩子是特定类型的对象列表的上下文中,表达关系的正确方法是什么?
谢谢!
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。