|
@@ -114,8 +114,23 @@ void add_boolean(JsonEncoder* this, char* key, boolean val){
|
|
|
free(str);
|
|
|
}
|
|
|
|
|
|
-void add_array(JsonEncoder* this, char* key, char* val){
|
|
|
- add_string(this, key, val); //Pas de gestion special
|
|
|
+void add_array(JsonEncoder* this, char* key, JsonArray* val){
|
|
|
+ //Verification
|
|
|
+ if(val->mode != JSON_ARRAY_ENCODER){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //Recup string du JsonEncoder
|
|
|
+ char* json;
|
|
|
+ json = json_encode_array(val);
|
|
|
+ //Creation chaine
|
|
|
+ int length = strlen(key) + strlen(json) + 2 + 2 + 1; //clef + val + 2 guillemets + ": " + \0
|
|
|
+ char* str = malloc(length * sizeof(char));
|
|
|
+ memset(str, 0, length);
|
|
|
+ sprintf(str, "\"%s\": %s", key, json);
|
|
|
+ //Ajout
|
|
|
+ add_value(this, str);
|
|
|
+ free(str);
|
|
|
+ free(json);
|
|
|
}
|
|
|
|
|
|
void add_object(JsonEncoder* this, char* key, JsonEncoder* val){
|