Re: Ignore JSON nesting

On Mar 13, 2014, at 6:51 AM, Bert Spaan <bert@waag.org> wrote:

> Gregg, 
> 
> Thanks for you answer.
> 
> I’ve found a solution for my problem, by using an extra predicate (‘geojsonProperties’, which can be ignored), and using the same @id twice. What do you think?

Sure, that should do it, you end up with an extra triple is all.

Gregg

> Permalink to JSON-LD playground:
> 
> http://json-ld.org/playground/index.html?json-ld=%7B%22%40context%22%3A%7B%22%40base%22%3A%22http%3A%2F%2Frdf.citysdk.eu%2Fams%2F%22%2C%22name%22%3A%22dc%3Atitle%22%2C%22cdk_id%22%3A%22cdk%3Acdk_id%22%2C%22features%22%3A%22cdk%3AapiResult%22%2C%22properties%22%3A%22cdk%3AgeojsonProperties%22%2C%22date_created%22%3A%22dc%3Adate%22%2C%22layers%22%3A%7B%22%40id%22%3A%22cdk%3AlayerOnObject%22%2C%22%40container%22%3A%22%40index%22%7D%2C%22data%22%3A%22cdk%3AlayerData%22%2C%22wkt%22%3A%22geos%3AhasGeometry%22%7D%2C%22%40id%22%3A%22http%3A%2F%2Fapi.citysdk.waag.org%2Fnodes%3Flayer%3Dadmr%26per_page%3D1%22%2C%22type%22%3A%22FeatureCollection%22%2C%22features%22%3A%5B%7B%22%40id%22%3A%22cdk%3Aobjects%2Fadmr.nl.appingedam%22%2C%22%40type%22%3A%22cdk%3ANode%22%2C%22type%22%3A%22Feature%22%2C%22wkt%22%3A%22POINT(6.86666%2053.31666)%22%2C%22geometry%22%3A%7B%22type%22%3A%22Point%22%2C%22coordinates%22%3A%5B6.86666%2C53.31666%5D%7D%2C%22properties%22%3A%7B%22%40id%22%3A%22cdk%3Aobjects%2Fadmr.nl.appingedam%22%2C%22cdk_id%22%3A%22admr.nl.appingedam%22%2C%22name%22%3A%22Appingedam%22%2C%22node_type%22%3A%22node%22%2C%22layer%22%3A%22admr%22%2C%22layers%22%3A%7B%22cbs%22%3A%7B%22%40id%22%3A%22cdk%3Alayers%2Fcbs%2Fobjects%2Fadmr.nl.appingedam%22%2C%22%40type%22%3A%22cdk%3ALayerOnObject%22%2C%22date_created%22%3A%222013-02-02%22%2C%22data%22%3A%7B%22%40id%22%3A%22cdk%3Aobjects%2Fadmr.nl.appingedam%2Flayers%2Fcbs%2F%22%2C%22%40type%22%3A%22cdk%3ALayerData%22%2C%22%40context%22%3A%7B%22name%22%3A%22dc%3Atitle%22%2C%22aant_inw%22%3A%22dbpedia%3ApopulationTotal%E2%80%8E%22%2C%22gm_code%22%3A%7B%22%40id%22%3A%22cdk%3Alayers%2Fcbs%2Ffields%2Fgm_code%22%2C%22%40type%22%3A%22xsd%3Astring%E2%80%8E%22%7D%2C%22opp_tot%22%3A%7B%22%40id%22%3A%22cdk%3Alayers%2Fcbs%2Ffields%2Fopp_tot%22%2C%22%40type%22%3A%22http%3A%2F%2Fdbpedia.org%2Fpage%2FHectare%E2%80%8E%22%7D%7D%2C%22name%22%3A%22Appingedam%22%2C%22gm_code%22%3A%22GM0003%22%2C%22gm_naam%22%3A%22Appingedam%22%2C%22opp_tot%22%3A%222458%22%2C%22aant_inw%22%3A%2212090%22%7D%7D%7D%7D%7D%5D%7D&frame=%7B%7D&context=%7B%0A%20%20%22%40context%22%3A%20%7B%0A%20%20%20%20%22name%22%3A%20%22http%3A%2F%2Fxmlns.com%2Ffoaf%2F0.1%2Fname%22%2C%0A%20%20%20%20%22homepage%22%3A%20%7B%0A%20%20%20%20%20%20%22%40id%22%3A%20%22http%3A%2F%2Fxmlns.com%2Ffoaf%2F0.1%2Fhomepage%22%2C%0A%20%20%20%20%20%20%22%40type%22%3A%20%22%40id%22%0A%20%20%20%20%7D%0A%20%20%7D%0A%7D&startTab=tab-nquads
> 
> Or only JSON-LD file:
> https://gist.githubusercontent.com/bertspaan/9524228/raw/b74d4d68c0980978707c9100ecec3471900d325b/json-ld.json
> 
> Thanks,
> Bert
> On 11 Mar 2014 at 17:36:15, Gregg Kellogg (gregg@greggkellogg.net) wrote:
> 
>> On Mar 11, 2014, at 6:15 AM, Bert Spaan <bert@waag.org> wrote:
>> 
>>> (I’m sorry if this message will appear on the mailing list twice, but it seems my attempt from this morning did not come through…)
>>> 
>>> Hi,
>>> 
>>> I'm working on an open data API which currently can serialize its output to GeoJSON or RDF/Turtle. I'm working on JSON-LD serialization, and ideally I would like to have a @context which I can add to the existing GeoJSON output (together with some @ids and @types), so that both the Turtle output and the JSON-LD output will normalize to the same triples.
>>> 
>>> Data is organized as follows: each object/feature has an ID and a name, and data on one or more layers. Per layer, there is a data field, which contains a JSON object. Example GeoJSON output:
>>> 
>>> {
>>>   "type": "FeatureCollection",   
>>>   "features": [
>>>     {
>>>       "type": "Feature",
>>>       "properties": {
>>>         "id": "admr.nl.appingedam",
>>>         "name": "Appingedam",
>>>         "layers": {
>>>           "cbs": {
>>>             "data": {
>>>               "name": "Appingedam",
>>>               "population": 1092
>>>             }
>>>           },
>>>           "admr": {
>>>               "data": {
>>>               "name": "Appingedam",
>>>                 "gme_code": 4654,
>>>                 "admn_level": 3
>>>               }
>>>           }
>>>         }
>>>       },
>>>       "geometry": {…}
>>>     }
>>>   ]
>>> }
>>> 
>>> Example Turtle output:
>>> 
>>> <admr.nl.appingedam>
>>>     a :Node ;
>>>     dc:title "Appingedam" ;
>>>     :createdOnLayer <layer/admr> ;
>>>     :layerData <admr.nl.appingedam/admr> ;
>>>     :layerData <admr..nl.appingedam/cbs> .
>>> <admr.nl.appingedam/admr>
>>>     a :LayerData ;
>>>     :definedOnLayer <layer/admr> ;
>>>     <layer/admr/name> "Appingedam" ;
>>>     <layer/admr/gme_code> "4654" .
>>>     <layer/admr/admn_level> "3" .
>>> <admr.nl.appingedam/cbs>
>>>     a :LayerData ;
>>>     :definedOnLayer <layer/cbs> ;
>>>     <layer/cbs/name> "Appingedam" ;
>>>     <layer/cbs/population> "1092" ;
>>> 
>>> The properties object does not have its own URI. Is there a way to create a JSON-LD context which takes the contents of the properties into account, but further 'ignores' its precence?
>> 
>> This is something that keeps coming up: having a transparent layer, that basically folds properties up a level. This was discussed during the development of JSON-LD, but ultimately it was rejected.
>> 
>> I don't see any prospects for doing something in the short-term, but it could be revisited in a possible future WG chartered with revising the spec. Feedback like this is quite useful.
>> 
>> In the mean time, you can play with different JSON-LD encodings that match your RDF though tools like http://json-ld.org/playground and my own http://rdf.greggkellogg.net/distiller.
>> 
>> Gregg
>> 
>>> Many thanks,
>>> 
>>> Bert Spaan
>>> 
>> 

Received on Thursday, 13 March 2014 16:01:55 UTC