Replies: 1 comment
-
Alright, I believe that I've made some progress with my understanding of JSON-LD and the various operations related to JSON-LD documents. If I for example take a JSON-LD document that's in the normalized and compacted form already nothing will happen if I run Compact against it with the appropriate (full) context - as expected. proc := ld.NewJsonLdProcessor()
options := ld.NewJsonLdOptions("")
// Ignore the details of these options, I've been experimenting. They're not relevant to the result.
options.OutputForm = "application/json"
options.CompactArrays = true
options.UseNativeTypes = true
options.ProduceGeneralizedRdf = true
options.OmitGraph = true
compactedDoc, err := proc.Compact(
"https://raw.githubusercontent.com/smart-data-models/dataModel.Device/refs/heads/master/Device/examples/example-normalized.jsonld",
map[string]interface{}{
"@context": []interface{}{
"https://raw.githubusercontent.com/smart-data-models/dataModel.Device/master/context.jsonld",
"https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld",
},
},
options,
)
if err != nil {
panic(err)
}
ld.PrintDocument("JSON-LD compaction succeeded", compactedDoc) This means that I'll still be left with nested objects with types and all that stuff. {
"@context": [
"https://raw.githubusercontent.com/smart-data-models/dataModel.Device/master/context.jsonld",
"https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld"
],
"batteryLevel": {
"type": "Property",
"value": 0.75
},
"controlledAsset": {
"object": "urn:ngsi-ld::wastecontainer-Osuna-100",
"type": "Relationship"
},
"controlledProperty": {
"type": "Property",
"value": [
"fillingLevel",
"temperature"
]
},
"dateFirstUsed": {
"type": "Property",
"value": {
"@value": "2014-09-11T11:00:00Z",
"type": "DateTime"
}
},
...
} Flattening / simplifying / getting rid of these isn't in the scope of this library if I understand correctly since the format doesn't have anything to do with JSON-LD but rather NGSI-LD? I'll check the NGSI-LD documentation if the process of simplifying these has a name and any specifications or official implementations. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I'm working on a project (data space) where we're dealing with JSON-LD documents, more specifically with NGSI-LD APIs and Smart Data Models in various JSON(-LD) forms.
If you take a look at https://ngsild.org/ there's an
A Simple Example
section. We'd like to build a "pipeline" that could simplify any form of a valid JSON-LD document (normalised, etc.) into its simplest form (ideally pure JSON).We'd then take that and validate it with the JSON schema for a specific data model provided by Smart Data Models (
schema.json
) and store it into a PostgreSQL compatible database, where we'd apply a compatible schema file for the model (schema.sql
).Let's take a look at the Device model for example. We'd like to be able to take any of the JSON-LD or pure JSON files from the model's example folder, simplify it down to its "purest" form (potentially with json-gold), validate it with the official JSON schema file for the model, and store it into a compatible PostgreSQL table, which would be created using the official SQL schema file for the model.
We're trying to figure out if json-gold is something that could help us with that. So far we've only experimented a bit and haven't yet tried all the options.
Any kind of hints / pointers / tips will be appreciated.
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions