FamilySearch / gedcomx

An open data model and an open serialization format for exchanging genealogical data.
http://www.gedcomx.org
Apache License 2.0
356 stars 67 forks source link

JSON field name containing dot #263

Closed MystEre84 closed 10 years ago

MystEre84 commented 10 years ago

Hi everyone!

I tried to insert the GedcomX example (found in GedcomX java class "ExampleGedcomxFileData") in a MongoDB database and got an error because field name of the "Identifier" data type ( https://github.com/FamilySearch/gedcomx/blob/master/specifications/json-format-specification.md#31-the-identifier-data-type ) contains dot. JSON doesn't have a problem with that but MongoDB does. It seems it's the only GedcomX element in this case and considering that dot is a special character wouldn't it be safer to modify these fields names?

Other question: is there some code to get GedcomX element from JSON?

Hoping that my english is understandable. MystEre

stoicflame commented 10 years ago

HI!

Ugh. I had no idea that MongoDB had that limitation. If I would have known earlier, I would have been more open to the change. But at this point, I think we need to keep it as defined, especially since this is a limitation of a specific product.

You may be stuck with editing those keys before you store it in Mongo.

We've initialized some projects for reading/writing GEDCOM X. The Java one is the most mature:

https://github.com/FamilySearch/gedcomx-java https://github.com/FamilySearch/gedcomx-csharp https://github.com/FamilySearch/gedcomx-php

We'd be happy to initialize projects for any other language or platform, too.

MystEre84 commented 10 years ago

Hi!

Thanks for your answer! Ok for the fields names, I understand.

I looked into the java project and found out how to get JSON from GedcomX but not the opposite, is it something implemented? if yes can you tell me where?

Have a good weekend

stoicflame commented 10 years ago

Yes, we need to get that documented.

Gedcomx document = ...;
org.gedcomx.rt.json.GedcomJacksonModule.createObjectMapper().writeValueAsString(document);
MystEre84 commented 10 years ago

Thanks a lot for your answer! I was searching for the opposite: getting GedcomX from a JSON string but your answer helped me anyway! Person person = GedcomJacksonModule.createObjectMapper(Person.class).readValue(jsonPersonString, Person.class);