Question

I am very new to the semantic web, VIE, and JSON-LD. I am using create.js to modify content on a page. When the data is saved, I get the following object on the server. Create.js suggests modifying backbone.sync but I don't know where to start with that.

array(
    '@subject' => '</nodes/edit/2>',
    '@type' => '<http://viejs.org/ns/Node>',
    '<http://viejs.org/ns/meta_title>' => 'The Node Title',
    '<http://viejs.org/ns/meta_description>' => 'The Node Description',
    '<http://viejs.org/ns/content>' => 'Going places on Sunday afternoon.'
)

I need this data in this format.

array(
    'Node'=>array(
         'id'=>2,
         'meta_title'=>'The Node Title',
         'meta_description'=>'The Node Description',
         'content'=>'Going places on Sunday afternoon'
    )
)

Does anyone know a common way of translating this kind of data?

Was it helpful?

Solution

Normally, you could just use a JSON-LD processor to transform the data to the above format using the compact API call and an appropriate context. Unfortunately, that data is using an obsolete version of JSON-LD, so that won't work. Sorry this comment isn't more helpful, but I thought it important to note there is a common way of doing what you want -- if the data is correct JSON-LD. VIE needs to be updated. See: http://github.com/bergie/VIE/issues/110

I'm sorry the problem isn't more easily solved. I'd recommend just writing your own custom processor for now. You could try writing something to translate the data to proper JSON-LD... because then you could use any JSON-LD processor to do whatever you needed. That tool might be more helpful to share with others who are using VIE while it is still out of date w/respect to JSON-LD. But that approach, of course, requires doing some reading/learning about JSON-LD, so it all depends on your time/interest.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top