json.h 935 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. * File: json.h
  3. * Author: Arthur Brandao
  4. *
  5. * Created on 28 octobre 2018, 17:53
  6. */
  7. #ifndef JSON_H
  8. #define JSON_H
  9. /* --- Include --- */
  10. #include <string.h>
  11. #include "boolean.h"
  12. /* --- Constante --- */
  13. #define JSON_ERROR -1
  14. #define JSON_OK 0
  15. #define JSON_STRING 1
  16. #define JSON_NUMBER 2
  17. #define JSON_BOOLEAN 3
  18. #define JSON_ARRAY 4
  19. #define JSON_OBJECT 5
  20. /* --- Structure --- */
  21. typedef struct{
  22. char* str; //La chaine de carac json
  23. int elt; //Le nombre d'element
  24. char** key; //La position des clef dans la chaine
  25. char** val; //La position de la valeur
  26. int* key_length; //La taille des clefs
  27. int* val_length; //La taille des valeurs
  28. int* type; //Le type des valeurs
  29. }JsonParser;
  30. /* --- fonctions ---- */
  31. int json_parse(JsonParser*, char*);
  32. void clean_json_parser(JsonParser*);
  33. int get_type(JsonParser*, char*);
  34. char* get(JsonParser*, char*);
  35. char* get_index(JsonParser*, int);
  36. #endif /* JSON_H */