json-ld.org icon indicating copy to clipboard operation
json-ld.org copied to clipboard

compacting nested values

Open LucaCerina opened this issue 4 years ago • 1 comments

Hello, considering an expanded json-ld in the form

"http://example.com/vocab/wake": [
  {
    "http://example.com/vocab/minutes": [
      {
        "@value": 15
      }
    ]
  }
]

what should I have in the compaction context to have something like:

"wake" : 15

thanks for the help

LucaCerina avatar Mar 27 '20 13:03 LucaCerina

Can't do that, I'm afraid. You can use Property Nesting to expand to that form, more or less.

{
  "@context": {
    "@vocab": "http://example.org/",
    "minutes": {"@nest": "wake"},
    "wake": "@nest"
  },
  "wake": {
    "minutes": 15
  }
}

Expands to:

[
  {
    "http://example.org/minutes": [
      {
        "@value": 15
      }
    ]
  }
]

gkellogg avatar May 22 '20 20:05 gkellogg