Welcome Guest! Log in
×

Notice

The forum is in read only mode.
The Stambia User Community is moving to Semarchy! All the applicable resources have already been moved or are currently being moved to their new location. Read more…

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
JSon dynamic anchors / balises JSon dynamique was created by Mickael_CarPostal
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
Replied by Thomas BLETON on 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
Replied by Mickael_CarPostal on 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
Replied by Thomas BLETON on 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
Replied by Thomas BLETON on 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