You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
... and return the values as a JS array. (This is real data I've used for demos and testing the SDK, using the Form Model syntax and vocabs).
Right now we have to run the results of values through a custom function that parses the collection recursively into an array by removing the rdf$first item, appending it to an array, then sending rdf$rest recursively into itself. The code snippet we use is here:
async function loopList(doc: any) {
let parts: any = []
const field = await doc.rdf$first
if (field) {
const nextField = await loopList(doc.rdf$rest)
parts = [...parts, field.value, ...nextField]
}
return parts
}
This currently works and returns a collection as an array, but something like this seems extremely useful for managing other datatypes than just Literals.
The text was updated successfully, but these errors were encountered:
Just want to note that we'll need to be careful with blank nodes (#34).
RubenVerborgh
changed the title
Fetch an RDF collection and return it as a Javascript array
Fetch an RDF list and return it as a Javascript array
Jan 12, 2020
It would be a very nice feature-add to be able to fetch an RDF collection such as:
... and return the values as a JS array. (This is real data I've used for demos and testing the SDK, using the Form Model syntax and vocabs).
Right now we have to run the results of values through a custom function that parses the collection recursively into an array by removing the
rdf$first
item, appending it to an array, then sendingrdf$rest
recursively into itself. The code snippet we use is here:This currently works and returns a collection as an array, but something like this seems extremely useful for managing other datatypes than just Literals.
The text was updated successfully, but these errors were encountered: