Welcome Guest! Log in
×

Notice

The forum is in read only mode.
Due to some maintenance operations, stambia.org will be switched to read-only mode during the 13th November. It will be possible to read and download, but impossible to post on the forums or create new accounts. For any question please contact the support team.

Topic-icon Question JSon dynamic anchors / balises JSon dynamique

  • Mickael_CarPostal
  • Mickael_CarPostal's Avatar Topic Author
  • Offline
More
25 Mar 2016 10:49 #1 by Mickael_CarPostal
Mickael_CarPostal created the topic: JSon dynamic anchors / balises JSon dynamique
Bonjour,

Petit défi technique pour la réalisation d'une extraction vers un fichier JSon.
En faisant un reverse d'un exemple fourni, j'ai le schéma suivant :

On remarque une section Data avec un contenu particulier concernant deux balises de type TimeTable et StopArea, sauf que ces balises ont pour nom la valeur stockée en base à extraire !
Exemple concret :


J'avoue être un peu à court d'idée ...
Je ne pense que de base le Designer gère les noms de balises dynamiquement. Ensuite, faut-il faire un mapping préliminaire construisant le contenu de la balise Data pour être exploitée dans un mapping final, quid ?

Toute bonne idée est la bienvenue ...

Mickaël MELKONIAN

Hello,

A small technical challenge to perform an extract to a JSon file.
After a sample reverse engeneering, I've got the following schem:

We can observe a "Data" section with a particular value concerning two kinds of anchors TimeTable and StopArea, in fact, those anchors are named with the database extracted value!

Concrete example :


I'm in lack of tricks...
I don't think that the Designer natively manages dynamic anchors. Therfore, must we create a preliminar mapping to prepare the value of the Data section to put and use it in the final mapping, I don't know ?

I'm an open mind person, so, if someone get a good idea, he/she's welcome...

Mickaël MELKONIAN
Attachments:
More
29 Mar 2016 11:29 #2 by Thomas BLETON
Thomas BLETON replied the topic: JSon dynamic anchors / balises JSon dynamique
Hi,
If I understand well, you have a source database, and you need to generate a json file from the this database.
And you want some Json field names to have a variable name, determined with the source data ?
  • Mickael_CarPostal
  • Mickael_CarPostal's Avatar Topic Author
  • Offline
More
29 Mar 2016 14:13 #3 by Mickael_CarPostal
Mickael_CarPostal replied the topic: JSon dynamic anchors / balises JSon dynamique
Hi,

Yes it is ...

The two difficulties are :
  • the JSon schem should be "universal", that's mean one timetable field name and one stoparea field name (which are both collections) instead of "timetable_1", "timetable_2' and "stoparea_A", "stoparea_B"
  • link those two Json variable field names with the data store in the source

Bonjour,

C'est bien cela

Les deux difficultés sont :
  • rendre universel le schéma JSon, ce qui signifie une balise "timetable" et une autre "stoparea" (qui désignent aussi une collection) au lieu de "timetable_1", "timetable_2' et "stoparea_A", "stoparea_B"
  • lier les nom de balises variables aux données stockées dans la source de données
More
01 Apr 2016 11:14 #4 by Thomas BLETON
Thomas BLETON replied the topic: JSon dynamic anchors / balises JSon dynamique
It is not possible to map a source column to a target Json field name. This is because the mapping needs "static" field names and clearly specified structures. So I think that the solution will not come from the mapping itself. I will check this again with our dev team to confirm that it is not possible within a mapping.

Another approach: maybe you can work with Scripting and generate a Json string in a script.
www.json.org/js.html

Note: we usually don't recommend to design data structure with variable field names.
I don't know if you have the possibility to alter this design, but just in case this is what I would personnaly try to do:
Instead of
"data" : {
"zest_timetable_769" : { sameStructure },
"zest_timetable_771" : { sameStructure },
....
}

Add a property like this:
"data" : {
"zest_timetable" : { "id": <string>, "structure": {sameStructure }}
}
... and the "id" would contain 769, 771, etc...
More
25 Oct 2018 17:23 #5 by Thomas BLETON
Thomas BLETON replied the topic: JSon dynamic anchors / balises JSon dynamique
Just a few words to say that Stambia DI now supports dynamic Json node names.

See here for more information :
www.stambia.org/doc/147-technology-artic...json-property-fields