Bonjour Falsam
Et pourtant voici un exemple qui fonctionne.
ComposeJSON(0) est une structure de type string
ces deux macros peuvent servir pour le debud _s(...) avec des doubles quotes pour chaque élément
Macro _q_t_
"
EndMacro
Macro _s (__S)
_q_t_#__S#=_q_t_+__S+" "
EndMacro
Code : Tout sélectionner
If CreateJSON(0)
ValeurTableau = SetJSONArray(JSONValue(0))
SetJSONString(AddJSONElement(ValeurTableau), "hello")
SetJSONString(AddJSONElement(ValeurTableau), "le Monde")
SetJSONString(AddJSONElement(ValeurTableau), "le Monde2")
; Debug _s(ComposeJSON(0))
Debug ComposeJSON(0)
EndIf
Debug "**** Maintenant en tableau ****"
Enumeration
#JSON
EndEnumeration
ParseJSON(#JSON,ComposeJSON(0))
Dim MyArray.s(#JSON)
ExtractJSONArray(JSONValue(#JSON), MyArray())
For i=0 To ArraySize(MyArray())
Debug MyArray(i)
Next
Autre exemple pas facile à coder le string$
Code : Tout sélectionner
Enumeration
#JSON
EndEnumeration
string$="["+Chr(34)+"Peche"+Chr(34)+","+Chr(34)+"Pomme"+Chr(34)+","+Chr(34)+"Poire"+Chr(34)+","+Chr(34)+"Abricot"+Chr(34)+","+Chr(34)+"Citron"+Chr(34)+"]"
Debug string$
ParseJSON(#JSON, string$)
Dim MyArray.s(#JSON)
ExtractJSONArray(JSONValue(#JSON), MyArray())
For i=0 To ArraySize(MyArray())
Debug MyArray(i)
Next
A+