lucmoreau / ProvToolbox

Java toolkit to create and convert W3C PROV data model representations, and build provenance-enabled applications in a variety of programming languages (java, python, typescript, javascript)
Other
74 stars 42 forks source link

unmodified prov-json documents cannot be stored in mongoDB due to field name restrictions #134

Open etorres opened 9 years ago

etorres commented 9 years ago

Field names in mongoDB cannot start with a dollar sign, making that prov-json documents cannot be stored without first being modified. This limitation is normally overcome by escaping the dollar sign (e.g using the Unicode full width equivalent).

It's very likely that similar limitations could be found in other document-oriented databases where field names usually have semantic meaning. I would be interested in having a general mechanism to make prov-json documents compatible with existing database systems.

Additional References:

trungdong commented 9 years ago

Hi @etorres,

Thank you for bringing this to our attention. We'd love to support the escaping you suggested as an output option.

We're currently using the gson library for JSON serialization. Allow me sometime to investigate how gson can support this kind of escaping.

tballast commented 2 years ago

Has this been addressed at all in the last years? We are facing the same issue and would love to be able to use the default output directly in MongoDB.

lucmoreau commented 2 years ago

We are routinely using the more recent prov-jsonld serialisation with mongodb without problem.

tballast commented 2 years ago

@lucmoreau Thanks you for your response. I have tried it and it looks like it should work. Is there a way to control which keys are added to the output though?

For example:

...
  "@graph" : [ {
    "@type" : "prov:Agent",
    "@id" : "pfx:entity::CompanyName",
    "efg:resourceType" : [ {
      "@value" : "entity"
    } ],
    "prov:role" : [ ],
    "prov:value" : [ ],
    "prov:type" : [ "prov:Organization" ],
    "prov:label" : [ ],
    "prov:location" : [ ]
  }, {
...

I don't need all of the empty fields to be present, and I don't believe that they are required either.

lucmoreau commented 2 years ago

Sorry, I have not been able to find how to control this in the serialisation, but suggestions most welcome 😉