ComposantsComponents › Traitement › ChampsProcessing › Fields
Construit un document JSON à partir des colonnes du flux, selon un arbre dessiné dans l'éditeur du composant, et le range dans une colonne de sortie. Sans Group by, chaque ligne entrante donne un document ; avec Group by, les lignes qui se suivent avec les mêmes valeurs forment un seul document, où elles deviennent un tableau. L'arbre est celui du tWriteXMLField : le composant écrit d'abord un XML, puis le convertit en JSON (bibliothèque json-lib), d'où quelques pièges sur les tableaux et les valeurs nulles. Pour relire des champs d'une colonne JSON, prenez un tExtractJSONFields. Builds a JSON document from the columns of the flow, following a tree drawn in the component editor, and stores it in an output column. Without Group by, each incoming row gives a document; with Group by, the rows that follow each other with the same values form a single document, where they become an array. The tree is the one of the tWriteXMLField: the component first writes an XML, then converts it to JSON (json-lib library), hence a few pitfalls about arrays and null values. To read fields back from a JSON column, take a tExtractJSONFields.
EntréeInput
Main un flux, obligatoire : ses colonnes alimentent l'arbreone flow, required: its columns feed the tree
SortieOutput
Main un flux, obligatoire : une ligne par document, avec la colonne JSON et les colonnes du Group byone flow, required: one row per document, with the JSON column and the Group by columns
Déclencheurs en sortieOutput triggers
On Component Ok On Component Error Run if
Chaque document sort dans une ligne, colonne json (String), sur une seule ligne de texte, pour être rangé en base, écrit dans un fichier ou envoyé plus loin.
Each document comes out in a row, json column (String), on a single line of text, to be stored in a database, written to a file or sent further.
Le JSON construit devient le corps renvoyé par le tRESTResponse (colonne de type String), ou envoyé par un tRESTClient. The JSON built becomes the body returned by the tRESTResponse (column of type String), or sent by a tRESTClient.
class = array sur l'élément qui contient la boucle pour obtenir toujours un tableau.
To gather several rows in one document, fill Group by and sort the flow on these columns. Add the class = array attribute on the element holding the loop to always get an array.
[].
In the Advanced settings, check Pass null values and empty strings explicitly: without it, a null or empty value is written [].
L'éditeur montre à gauche les colonnes du flux entrant, à droite l'arbre. Clic droit sur un nœud : Ajouter un sous-élément, Ajouter un attribut, Définir une valeur fixe, Définir comme élément de boucle, Définir comme élément de groupe, Importer l'arborescence XML. Une colonne glissée sur un nœud s'y lie. L'arbre est enregistré, comme celui du tWriteXMLField, dans trois tables masquées, ROOT, GROUP et LOOP. À la génération, les éléments deviennent des clés, selon les règles suivantes, observées sur les exemples de cette page :
The editor shows on the left the columns of the incoming flow, on the right the tree. Right-click on a node: Add Sub-element, Add Attribute, Set a fixed value, Set As Loop Element, Set As Group Element, Import XML Tree. A column dragged on a node gets linked to it. The tree is saved, as the one of the tWriteXMLField, in three hidden tables, ROOT, GROUP and LOOP. At generation, the elements become keys, following the rules below, observed on the examples of this page:
customers
└─ customer boucleloop
├─ id ← id
├─ name ← name
└─ city ← city
{"customers":{"customer":{"id":1,"name":"Ada","city":"London"}}}
La racine est la seule clé du document, sauf si Supprimer le nœud racine. est coché : {"customer":{…}}.
The root is the only key of the document, unless Remove root node. is checked: {"customer":{…}}.
true/false, le reste en texte.Element linked to a column: a key and its value. Integer, Long, Double, BigDecimal… are written as numbers, Boolean as true/false, the rest as text."customers":[…]) ; avec d'autres enfants, leur clé reçoit le tableau ("city":[…]). Un seul élément : un objet, nom compris.Repeated elements (the loop, when the group has several rows): alone under their parent, the parent becomes an array of their contents and their name disappears ("customers":[…]); with other children, their key gets the array ("city":[…]). A single element: an object, name included.class de valeur fixe array sur ce parent : toujours un tableau, même d'un élément.class attribute with the fixed value array on this parent: always an array, even of one element.type de valeur fixe string, number ou boolean sur un élément : impose le type de sa valeur.type attribute with the fixed value string, number or boolean on an element: forces the type of its value.@nom, toujours en texte ; un élément qui a un attribut et une valeur devient {"@zone":"1","#text":"London"}.Other attribute: a @name key, always as text; an element having an attribute and a value becomes {"@zone":"1","#text":"London"}.
Les noms des nœuds sont des noms XML : une lettre ou _ en premier, pas d'espace ; une clé JSON comme first name ou 1st ne peut pas s'écrire. Talaxie 9.0.6 propose aussi Ajouter un espace de noms, que le Studio masque pour ce composant : l'espace est ignoré et son préfixe reste dans la clé ("x:name":"Ada"). À partir de Talaxie 9.0.7, l'action est masquée comme dans le Studio, et une colonne lâchée sur un nœud ne propose plus d'en faire un attribut.
Node names are XML names: a letter or _ first, no space; a JSON key like first name or 1st cannot be written. Talaxie 9.0.6 also offers Add Name Space, which the Studio hides for this component: the namespace is ignored and its prefix stays in the key ("x:name":"Ada"). From Talaxie 9.0.7, the action is hidden as in the Studio, and a column dropped on a node no longer offers to make it an attribute.
Les libellés sont ceux de l'onglet Composant ; le nom technique, en gris, est celui du paramètre dans le fichier du job. Labels are those of the Component tab; the technical name, in grey, is the parameter name in the job file.
| ParamètreSetting | DéfautDefault | VisibleShown | Description |
|---|---|---|---|
| Type de propriétéProperty TypePROPERTY | Built-inBuilt-In | ToujoursAlways | Built-in : l'arbre est dessiné dans le composant. Référentiel : il vient d'une métadonnée JSON de sortie du Référentiel. Built-In: the tree is drawn in the component. Repository: it comes from an output JSON metadata of the Repository. |
| Colonne de sortieOutput ColumnJSONFIELD | — | ToujoursAlways | La colonne du schéma qui reçoit le document, en texte compact sur une ligne. The schema column that gets the document, as compact text on one line. |
| Configurer la structure JSONConfigure JSON TreeMAP | — | ToujoursAlways |
Bouton qui ouvre l'éditeur de l'arbre (voir la structure JSON). L'arbre est rangé dans les tables masquées ROOT, GROUP et LOOP.
Button that opens the tree editor (see the JSON tree). The tree is stored in the hidden tables ROOT, GROUP and LOOP.
|
| SchémaSchemaSCHEMA | — | ToujoursAlways | Le schéma de sortie : la colonne JSON, et les colonnes que remplit le Group by. L'arbre, lui, se lie aux colonnes du flux entrant. The output schema: the JSON column, and the columns filled by the Group by. The tree is linked to the columns of the incoming flow. |
| Group byGROUPBYS | videempty | ToujoursAlways | Une ligne par colonne de regroupement : Colonne d'entrée (celle qui délimite les documents) et Colonne de sortie (celle qui reçoit sa valeur ; choisir la colonne JSON n'y recopie rien). Les lignes qui se suivent avec les mêmes valeurs forment un document ; un changement de valeur en commence un autre. Vide : un document par ligne entrante. One row per grouping column: Input column (the one delimiting the documents) and Output column (the one getting its value; choosing the JSON column copies nothing there). The rows that follow each other with the same values form a document; a change of value starts another one. Empty: one document per incoming row. |
| Supprimer le nœud racine.Remove root node.REMOVE_ROOT | NonNo | ToujoursAlways |
Cochée, le document est le contenu de la racine : {"id":"A-1",…} au lieu de {"order":{"id":"A-1",…}}, ou un tableau […] si la racine en est un.
Checked, the document is the content of the root: {"id":"A-1",…} instead of {"order":{"id":"A-1",…}}, or an array […] if the root is one.
|
| ParamètreSetting | DéfautDefault | VisibleShown | Description |
|---|---|---|---|
| Entourer de guillemets toutes les valeurs non nullesQuote all non-null valuesQUOTE_ALL_VALUES | NonNo | ToujoursAlways |
Nombres et booléens s'écrivent en texte : "id":"1", "active":"true". Le texte est celui de Java : un Double s'écrit "1.23456789015E10", un BigDecimal garde ses zéros ("1234.50").
Numbers and booleans are written as text: "id":"1", "active":"true". The text is the Java one: a Double is written "1.23456789015E10", a BigDecimal keeps its zeros ("1234.50").
|
| Entourer de guillemets les valeurs nullesQuote also null valuesQUOTE_NULL_VALUES | OuiYes | Guillemets cochésQuote checked |
N'agit que si Passer les valeurs nulles… est aussi coché : une valeur nulle s'écrit alors "null" (un texte) au lieu de null. Décochez-la pour garder un vrai null (voir l'exemple).
Only acts if Pass null values… is also checked: a null value is then written "null" (a text) instead of null. Uncheck it to keep a real null (see the example).
|
| Passer les valeurs nulles et les chaînes de caractères vides explicitementPass null values and empty strings explicitlyALLOW_EMPTY_STRINGS | NonNo | ToujoursAlways |
Décochée (défaut), une colonne nulle ou vide s'écrit [], un tableau vide. Cochée : null et "".
Unchecked (default), a null or empty column is written [], an empty array. Checked: null and "".
|
| Utiliser la notation scientifique pour les valeurs flottantesUse scientific notation for float valuesUSE_SCIENTIFIC_NOTATION | NonNo | ToujoursAlways |
Cochée, les nombres décimaux très grands ou très petits s'écrivent en notation scientifique : 1.23456789015E10, 1.0E-5 au lieu de 12345678901.5, 0.00001.
Checked, very large or very small decimal numbers are written in scientific notation: 1.23456789015E10, 1.0E-5 instead of 12345678901.5, 0.00001.
|
Un paramètre masqué, Format compact (COMPACT_FORMAT, coché), écrit le XML intermédiaire sans indentation.
A hidden setting, Compact Format (COMPACT_FORMAT, checked), writes the intermediate XML without indentation.
NB_LINE (Integer, disponible après l'exécution du composant) : nombre de documents produits, c'est-à-dire de lignes sorties. Avec Group by sur la ville, 3 lignes reçues donnent 2 ; aucune ligne reçue donne 0 (et aucun document). NB_LINE (Integer, available after the component has run): number of documents produced, that is of rows sent out. With Group by on the city, 3 received rows give 2; no row received gives 0 (and no document).
((Integer) globalMap.get("tWriteJSONField_1_NB_LINE"))
Le composant est virtuel : à la génération, il se dédouble en tWriteJSONField_1_Out, le tWriteXMLFieldOut qui reçoit les lignes et construit le XML, et tWriteJSONField_1_In, qui le convertit en JSON et l'envoie au composant suivant. Le premier range le nombre de lignes reçues dans tWriteJSONField_1_Out_NB_LINE, une variable que le composant ne déclare pas ; tWriteJSONField_1_In_NB_LINE n'existe pas.
The component is virtual: at generation, it splits into tWriteJSONField_1_Out, the tWriteXMLFieldOut which receives the rows and builds the XML, and tWriteJSONField_1_In, which converts it to JSON and sends it to the next component. The first one stores the number of received rows in tWriteJSONField_1_Out_NB_LINE, a variable the component does not declare; tWriteJSONField_1_In_NB_LINE does not exist.
Un tFixedFlowInput envoie les lignes au tWriteJSONField, dont la sortie est affichée par un tLogRow en mode simple (colonnes séparées par |) ; un tJava relié par On Subjob Ok affiche les variables globales. Quand un job enchaîne plusieurs sous-jobs, un tJava affiche avant chacun une ligne === …. Les sorties sont copiées depuis des exécutions des jobs dans Talaxie (Java 21). Lignes d'entrée de la plupart des exemples :
A tFixedFlowInput sends the rows to the tWriteJSONField, whose output is printed by a tLogRow in basic mode (columns separated by |); a tJava connected with On Subjob Ok prints the global variables. When a job chains several subjobs, a tJava prints a === … line before each one. The outputs are copied from runs of the jobs in Talaxie (Java 21). Input rows of most examples:
| idInteger | nameString | cityString |
|---|---|---|
| 1 | Ada | London |
| 2 | Alan | London |
| 3 | Grace | New York |
Arbre de la structure JSON, schéma de sortie json (String), réglages par défaut. Code du tJava :
Tree of the JSON tree, output schema json (String), default settings. tJava code:
System.out.println("tWriteJSONField_1_NB_LINE: " + globalMap.get("tWriteJSONField_1_NB_LINE"));
System.out.println("tWriteJSONField_1_Out_NB_LINE: " + globalMap.get("tWriteJSONField_1_Out_NB_LINE"));
System.out.println("tWriteJSONField_1_In_NB_LINE: " + globalMap.get("tWriteJSONField_1_In_NB_LINE"));
{"customers":{"customer":{"id":1,"name":"Ada","city":"London"}}}
{"customers":{"customer":{"id":2,"name":"Alan","city":"London"}}}
{"customers":{"customer":{"id":3,"name":"Grace","city":"New York"}}}
tWriteJSONField_1_NB_LINE: 3
tWriteJSONField_1_Out_NB_LINE: 3
tWriteJSONField_1_In_NB_LINE: null
Avec Supprimer le nœud racine. coché : With Remove root node. checked:
{"customer":{"id":1,"name":"Ada","city":"London"}}
{"customer":{"id":2,"name":"Alan","city":"London"}}
{"customer":{"id":3,"name":"Grace","city":"New York"}}
Schéma de sortie city, json ; Group by : colonne de sortie city, colonne d'entrée city. Quatre sous-jobs : l'arbre ci-dessus ; le même avec l'attribut class = array sur customers ; celui-ci avec Supprimer le nœud racine. ; l'arbre ci-dessus avec Supprimer le nœud racine.
Output schema city, json; Group by: output column city, input column city. Four subjobs: the tree above; the same with the class = array attribute on customers; this one with Remove root node.; the tree above with Remove root node.
=== group by city
London|{"customers":[{"id":1,"name":"Ada","city":"London"},{"id":2,"name":"Alan","city":"London"}]}
New York|{"customers":{"customer":{"id":3,"name":"Grace","city":"New York"}}}
=== group by city, class=array on customers
London|{"customers":[{"id":1,"name":"Ada","city":"London"},{"id":2,"name":"Alan","city":"London"}]}
New York|{"customers":[{"id":3,"name":"Grace","city":"New York"}]}
=== same, remove root
London|[{"id":1,"name":"Ada","city":"London"},{"id":2,"name":"Alan","city":"London"}]
New York|[{"id":3,"name":"Grace","city":"New York"}]
=== group by city, remove root, no class
London|[{"id":1,"name":"Ada","city":"London"},{"id":2,"name":"Alan","city":"London"}]
New York|{"customer":{"id":3,"name":"Grace","city":"New York"}}
tWriteJSONField_1_NB_LINE: 2
tWriteJSONField_2_NB_LINE: 2
Sans class, London (deux clients) donne un tableau où la clé customer a disparu, New York (un seul) un objet : deux formes pour le même arbre. Avec class = array, toujours un tableau.
Without class, London (two customers) gives an array where the customer key has disappeared, New York (only one) an object: two shapes for the same tree. With class = array, always an array.
| orderString | customerString | skuString | qtyInteger |
|---|---|---|---|
| A-1 | Ada | P1 | 2 |
| A-1 | Ada | P2 | 1 |
| A-2 | Alan | P3 | 5 |
order
├─ id ← order
├─ customer ← customer
└─ lines
├─ @class = array
└─ line boucleloop
├─ sku ← sku
└─ qty ← qty
Schéma de sortie order, json ; Group by sur order. Trois sous-jobs : cet arbre et Supprimer le nœud racine. ; sans l'attribut class ; avec l'attribut, racine gardée.
Output schema order, json; Group by on order. Three subjobs: this tree and Remove root node.; without the class attribute; with the attribute, root kept.
=== lines with class=array, remove root
A-1|{"id":"A-1","customer":"Ada","lines":[{"sku":"P1","qty":2},{"sku":"P2","qty":1}]}
A-2|{"id":"A-2","customer":"Alan","lines":[{"sku":"P3","qty":5}]}
=== lines without class, remove root
A-1|{"id":"A-1","customer":"Ada","lines":[{"sku":"P1","qty":2},{"sku":"P2","qty":1}]}
A-2|{"id":"A-2","customer":"Alan","lines":{"line":{"sku":"P3","qty":5}}}
=== lines with class=array, root kept
A-1|{"order":{"id":"A-1","customer":"Ada","lines":[{"sku":"P1","qty":2},{"sku":"P2","qty":1}]}}
A-2|{"order":{"id":"A-2","customer":"Alan","lines":[{"sku":"P3","qty":5}]}}
tWriteJSONField_1_NB_LINE: 2
tWriteJSONField_2_NB_LINE: 2
tWriteJSONField_3_NB_LINE: 2
Les éléments hors de la boucle (id, customer) sont écrits une fois par document. C'est la forme la plus courante d'un corps d'API : la racine supprimée, les lignes dans un tableau sûr. Relu par un tExtractJSONFields (boucle "$.lines[*]", "$.id" lu dans le document), le premier redonne les trois lignes :
The elements outside the loop (id, customer) are written once per document. It is the most common shape of an API body: root removed, lines in a safe array. Read back by a tExtractJSONFields ("$.lines[*]" loop, "$.id" read in the document), the first one gives back the three rows:
.-----+---+---. | tLogRow_1 | |=----+---+--=| |order|sku|qty| |=----+---+--=| |A-1 |P1 |2 | |A-1 |P2 |1 | |A-2 |P3 |5 | '-----+---+---'
Lignes (UK, London, 1, Ada), (UK, London, 2, Alan), (UK, Manchester, 3, Tom), (US, Boston, 4, Margaret). Arbre : country > code ← country, city en élément de groupe > name ← city et customer en boucle > id, name. Group by sur country, racine supprimée.
Rows (UK, London, 1, Ada), (UK, London, 2, Alan), (UK, Manchester, 3, Tom), (US, Boston, 4, Margaret). Tree: country > code ← country, city as group element > name ← city and customer as loop > id, name. Group by on country, root removed.
UK|{"code":"UK","city":[{"name":"London","customer":[{"id":1,"name":"Ada"},{"id":2,"name":"Alan"}]},{"name":"Manchester","customer":{"id":3,"name":"Tom"}}]}
US|{"code":"US","city":{"name":"Boston","customer":{"id":4,"name":"Margaret"}}}
tWriteJSONField_1_NB_LINE: 2
Les villes du Royaume-Uni forment un tableau, celle des États-Unis un objet ; de même pour les clients. Ici, les éléments répétés gardent leur nom (city, customer) parce que leur parent a d'autres enfants.
The cities of the UK form an array, the one of the US an object; the same for the customers. Here, the repeated elements keep their name (city, customer) because their parent has other children.
Lignes Ada (London), Grace (New York), Alan (London), Group by sur city, class = array, racine supprimée.
Rows Ada (London), Grace (New York), Alan (London), Group by on city, class = array, root removed.
London|[{"id":1,"name":"Ada"}]
New York|[{"id":3,"name":"Grace"}]
London|[{"id":2,"name":"Alan"}]
tWriteJSONField_1_NB_LINE: 3
tWriteJSONField_1_Out_NB_LINE: 3
Un document se ferme dès que la valeur change : London sort deux fois. Triez le flux avant, par un tSortRow. A document is closed as soon as the value changes: London comes out twice. Sort the flow before, with a tSortRow.
Une ligne, un élément par colonne sous la boucle item : id (Integer) 1, price (Double) 9.5, amount (BigDecimal) 1234.50, active (Boolean) true, puis des colonnes String : code "007", text_true "true", text_num "42", text_json "[1,2]", text_null "null" ; born (Date, motif "yyyy-MM-dd") 1815-12-10, big (Double) 12345678901.5, small (Float) 0.00001. Réglages par défaut, puis Entourer de guillemets toutes les valeurs non nulles, puis Utiliser la notation scientifique… :
One row, one element per column under the item loop: id (Integer) 1, price (Double) 9.5, amount (BigDecimal) 1234.50, active (Boolean) true, then String columns: code "007", text_true "true", text_num "42", text_json "[1,2]", text_null "null"; born (Date, pattern "yyyy-MM-dd") 1815-12-10, big (Double) 12345678901.5, small (Float) 0.00001. Default settings, then Quote all non-null values, then Use scientific notation…:
=== default
{"items":{"item":{"id":1,"price":9.5,"amount":1234.5,"active":true,"code":"007","text_true":"true","text_num":"42","text_json":[1,2],"text_null":null,"born":"1815-12-10","big":12345678901.5,"small":0.00001}}}
=== QUOTE_ALL_VALUES
{"items":{"item":{"id":"1","price":"9.5","amount":"1234.50","active":"true","code":"007","text_true":"true","text_num":"42","text_json":[1,2],"text_null":"null","born":"1815-12-10","big":"1.23456789015E10","small":"1.0E-5"}}}
=== USE_SCIENTIFIC_NOTATION
{"items":{"item":{"id":1,"price":9.5,"amount":1234.5,"active":true,"code":"007","text_true":"true","text_num":"42","text_json":[1,2],"text_null":null,"born":"1815-12-10","big":1.23456789015E10,"small":1.0E-5}}}
Le type de la colonne décide : un texte "42" reste un texte. Mais un texte qui ressemble à du JSON est lu comme tel : "[1,2]" devient un tableau et "null" un null, même avec les guillemets pour le premier (voir les pièges). Un BigDecimal perd ses zéros de fin en nombre. Une date s'écrit en texte, avec le motif de sa colonne.
The type of the column decides: a text "42" stays a text. But a text that looks like JSON is read as such: "[1,2]" becomes an array and "null" a null, even with quotes for the first one (see the pitfalls). A BigDecimal loses its trailing zeros as a number. A date is written as text, with the pattern of its column.
Lignes (1, Ada, London), (2, Alan, null), (3, Grace, ""), (4, null, null), arbre de la structure JSON, six combinaisons des réglages avancés :
Rows (1, Ada, London), (2, Alan, null), (3, Grace, ""), (4, null, null), tree of the JSON tree, six combinations of the advanced settings:
=== default
{"customers":{"customer":{"id":1,"name":"Ada","city":"London"}}}
{"customers":{"customer":{"id":2,"name":"Alan","city":[]}}}
{"customers":{"customer":{"id":3,"name":"Grace","city":[]}}}
{"customers":{"customer":{"id":4,"name":[],"city":[]}}}
=== ALLOW_EMPTY_STRINGS
{"customers":{"customer":{"id":1,"name":"Ada","city":"London"}}}
{"customers":{"customer":{"id":2,"name":"Alan","city":null}}}
{"customers":{"customer":{"id":3,"name":"Grace","city":""}}}
{"customers":{"customer":{"id":4,"name":null,"city":null}}}
=== QUOTE_ALL_VALUES (QUOTE_NULL_VALUES true)
{"customers":{"customer":{"id":"1","name":"Ada","city":"London"}}}
{"customers":{"customer":{"id":"2","name":"Alan","city":[]}}}
{"customers":{"customer":{"id":"3","name":"Grace","city":[]}}}
{"customers":{"customer":{"id":"4","name":[],"city":[]}}}
=== QUOTE_ALL_VALUES, QUOTE_NULL_VALUES false
{"customers":{"customer":{"id":"1","name":"Ada","city":"London"}}}
{"customers":{"customer":{"id":"2","name":"Alan","city":[]}}}
{"customers":{"customer":{"id":"3","name":"Grace","city":[]}}}
{"customers":{"customer":{"id":"4","name":[],"city":[]}}}
=== QUOTE_ALL_VALUES + ALLOW_EMPTY_STRINGS
{"customers":{"customer":{"id":"1","name":"Ada","city":"London"}}}
{"customers":{"customer":{"id":"2","name":"Alan","city":"null"}}}
{"customers":{"customer":{"id":"3","name":"Grace","city":""}}}
{"customers":{"customer":{"id":"4","name":"null","city":"null"}}}
=== QUOTE_ALL_VALUES + ALLOW_EMPTY_STRINGS, QUOTE_NULL false
{"customers":{"customer":{"id":"1","name":"Ada","city":"London"}}}
{"customers":{"customer":{"id":"2","name":"Alan","city":null}}}
{"customers":{"customer":{"id":"3","name":"Grace","city":""}}}
{"customers":{"customer":{"id":"4","name":null,"city":null}}}
Par défaut, nul et vide deviennent [], que le lecteur prendra pour un tableau. Passer les valeurs nulles… donne null et "". Avec les guillemets en plus, une nulle devient le texte "null", sauf si Entourer de guillemets les valeurs nulles est décochée.
By default, null and empty become [], which the reader will take for an array. Pass null values… gives null and "". With quotes as well, a null becomes the text "null", unless Quote also null values is unchecked.
Première ligne. Arbre : customers > source (valeur fixe crm), customer en boucle > attribut id ← id, name, status (valeur fixe active), city ← city avec un attribut zone (valeur fixe 1) :
First row. Tree: customers > source (fixed value crm), customer as loop > id attribute ← id, name, status (fixed value active), city ← city with a zone attribute (fixed value 1):
{"customers":{"source":"crm","customer":{"@id":"1","name":"Ada","status":"active","city":{"@zone":"1","#text":"London"}}}}
Ligne id 1 (Integer), code "42" et flag "true" (String), chaque élément avec un attribut type fixe : string, number, boolean ; racine supprimée :
Row id 1 (Integer), code "42" and flag "true" (String), each element with a fixed type attribute: string, number, boolean; root removed:
{"customer":{"id":"1","code":42,"flag":true}}
Caractères spéciaux (name = Tom & "Jerry" <b>, city avec un saut de ligne et une barre oblique inverse), racine supprimée :
Special characters (name = Tom & "Jerry" <b>, city with a line break and a backslash), root removed:
{"customer":{"id":1,"name":"Tom & \"Jerry\" <b>","city":"Paris\nLyon\\Nice"}}
Les caractères sont échappés comme le veut JSON. Un attribut s'écrit toujours en texte ("@id":"1") : pour un identifiant numérique, prenez un élément.
Characters are escaped as JSON requires. An attribute is always written as text ("@id":"1"): for a numeric identifier, take an element.
La conversion du XML ne sait pas qu'un élément répété est un tableau : avec un seul élément, elle écrit un objet, et sa clé ("lines":{"line":{…}} au lieu de "lines":[{…}]). Un client qui attend un tableau échoue alors sur les commandes d'une seule ligne. Mettez toujours l'attribut class = array sur le parent de la boucle (voir l'exemple).
The conversion from XML does not know that a repeated element is an array: with a single element, it writes an object, and its key ("lines":{"line":{…}} instead of "lines":[{…}]). A client expecting an array then fails on the orders of a single line. Always put the class = array attribute on the parent of the loop (see the example).
[]Null or empty: []
Par défaut, une colonne nulle ou vide s'écrit []. Cochez Passer les valeurs nulles et les chaînes de caractères vides explicitement pour obtenir null et "" ; avec Entourer de guillemets toutes les valeurs non nulles, décochez aussi Entourer de guillemets les valeurs nulles, sinon une nulle devient "null" (voir l'exemple).
By default, a null or empty column is written []. Check Pass null values and empty strings explicitly to get null and ""; with Quote all non-null values, also uncheck Quote also null values, otherwise a null becomes "null" (see the example).
Défaut de la conversion (bibliothèque json-lib) : un texte [1,2] devient un tableau, même avec Entourer de guillemets toutes les valeurs non nulles, et un texte null devient null sans cette case (voir l'exemple des types). Un commentaire saisi par un utilisateur peut ainsi changer la forme du document.
Defect of the conversion (json-lib library): a text [1,2] becomes an array, even with Quote all non-null values, and a text null becomes null without this box (see the types example). A comment typed by a user can thus change the shape of the document.
Le Group by ne trie pas : il ferme un document dès que la valeur change. Triez le flux sur les colonnes du Group by avant le composant (voir l'exemple du flux non trié). The Group by does not sort: it closes a document as soon as the value changes. Sort the flow on the Group by columns before the component (see the unsorted flow example).
Pour écrire un fichier d'objets à plat, une ligne par objet, le tFileOutputJSON suffit. Le tWriteJSONField sert aux objets imbriqués et aux tableaux ; pour un fichier, reliez sa sortie à un tFileOutputDelimited d'une seule colonne. To write a file of flat objects, one row per object, the tFileOutputJSON is enough. The tWriteJSONField is for nested objects and arrays; for a file, connect its output to a tFileOutputDelimited with a single column.
Les clés sortent dans l'ordre de l'arbre, où l'éditeur range les attributs (@…) avant les éléments. Pour changer l'ordre du document, changez celui des nœuds.
Keys come out in the order of the tree, where the editor puts the attributes (@…) before the elements. To change the order of the document, change the one of the nodes.
tExtractJSONFields · relire des champs d'une colonne JSONread fields from a JSON columntWriteXMLField · le même arbre, en XMLthe same tree, in XMLtFileOutputJSON · écrire un fichier JSON à platwrite a flat JSON filetSortRow · trier le flux avant un Group bysort the flow before a Group bytRESTResponse · renvoyer le JSON à l'appelant d'un servicereturn the JSON to the caller of a servicetXMLMap · construire des documents XML en mappantbuild XML documents by mapping