[Delphi XE] JSON : iSuperObject - Création d'un JSON multi niveau
Bonjour voici mon code (Utilisation de ISuperObject) :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| aJSONChannel := SO;
for J := 0 to ListTest.Count - 1 do
begin
aJSONChannel.S['a'] := ListTest[j].Code;
aJSONChannel.S['b'] := ListTest[j].Valeur;
// Create node "tranlsations"
aJSONChannel.O['translations'] := SA([]);
for I := 0 to ListTest[j].ListTranslation.Count-1 do
begin
aJSONTransaltionsLang := SO;
aJSONTransaltionsLang.S['title'] := ListTest[j].ListTranslation[i].Title;
aJSONChannel.A['translations'].Add(aJSONTransaltions);
end; |
et voici le résultat :
Code:
1 2 3 4 5 6 7 8 9
| {
"b": "valeur",
"a": "code",
"translations": [
{"title" : "fr"},
{"title" : "en"},
{"title" : "de"},
{"title" : "it"}],
} |
Ce que je veux faire c'est d'arriver à ceci :
Code:
1 2 3 4 5 6 7 8 9
| {
"b": "valeur",
"a": "code",
"translations": [
"fr" : {"title" : "fr"},
"en" : {"title" : "en"},
"de" : {"title" : "de"},
"it" : {"title" : "it"}],
} |
Pour moi il faudrait que je rajoute un node entre {translations} et le bloc {title} , c'est à dire ajouter un objet dans un objet (un SO dans un SO)