|
@@ -8,3 +8,72 @@
|
|
|
#include <stdlib.h>
|
|
|
#include "json.h"
|
|
|
|
|
|
+/* --- Fonctions privée --- */
|
|
|
+
|
|
|
+void add_node(JsonEncoder* this, char* key, char* val){
|
|
|
+ //Création node
|
|
|
+ JsonNode* node;
|
|
|
+ node = malloc(sizeof(JsonNode));
|
|
|
+ //Allocation node
|
|
|
+ node->key = malloc(strlen(key) * sizeof(char));
|
|
|
+ node->val = malloc(strlen(val) * sizeof(char));
|
|
|
+ //Initialisation node
|
|
|
+ strcpy(node->key, key);
|
|
|
+ strcpy(node->val, val);
|
|
|
+ //Si 1er node
|
|
|
+ if(this->head == NULL){
|
|
|
+ this->head = node;
|
|
|
+ node->prev = NULL;
|
|
|
+ } else {
|
|
|
+ node->prev = this->tail;
|
|
|
+ node->prev->next = node;
|
|
|
+ }
|
|
|
+ this->tail = node;
|
|
|
+ node->next = NULL;
|
|
|
+}
|
|
|
+
|
|
|
+void delete_node(JsonNode* node){
|
|
|
+ free(node->key);
|
|
|
+ free(node->val);
|
|
|
+ free(node);
|
|
|
+}
|
|
|
+
|
|
|
+/* --- Fonctions publique --- */
|
|
|
+
|
|
|
+void ini_encoder(JsonEncoder* this){
|
|
|
+ this->head = NULL;
|
|
|
+ this->tail = NULL;
|
|
|
+ this->length = 0;
|
|
|
+}
|
|
|
+
|
|
|
+int add_value(JsonEncoder* this, char* key, char* val){
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+int add_number(JsonEncoder*, double){
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+int add_integer(JsonEncoder*, int){
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+int add_boolean(JsonEncoder*, boolean){
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+int add_array(JsonEncoder*, char*){
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+int add_object(JsonEncoder*, JsonEncoder){
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+char* json_encode(JsonEncoder*){
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+void clean_json_encoder(JsonEncoder* this){
|
|
|
+
|
|
|
+}
|