json.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. /**
  2. * \file
  3. * JSON writer
  4. *
  5. * Author:
  6. * Joao Matos (joao.matos@xamarin.com)
  7. *
  8. * Copyright 2015 Xamarin Inc (http://www.xamarin.com)
  9. * Licensed under the MIT license. See LICENSE file in the project root for full license information.
  10. */
  11. #ifndef __MONO_UTILS_JSON_H__
  12. #define __MONO_UTILS_JSON_H__
  13. #include <glib.h>
  14. #define JSON_INDENT_VALUE 2
  15. typedef struct JsonWriter {
  16. GString* text;
  17. int indent;
  18. } JsonWriter;
  19. void mono_json_writer_init (JsonWriter* writer);
  20. void mono_json_writer_destroy (JsonWriter* writer);
  21. void mono_json_writer_indent(JsonWriter* writer);
  22. void mono_json_writer_indent_push(JsonWriter* writer);
  23. void mono_json_writer_indent_pop(JsonWriter* writer);
  24. void mono_json_writer_vprintf(JsonWriter* writer, const gchar *format, va_list args);
  25. void mono_json_writer_printf(JsonWriter* writer, const gchar *format, ...);
  26. void mono_json_writer_array_begin(JsonWriter* writer);
  27. void mono_json_writer_array_end(JsonWriter* writer);
  28. void mono_json_writer_object_begin(JsonWriter* writer);
  29. void mono_json_writer_object_end(JsonWriter* writer);
  30. void mono_json_writer_object_key(JsonWriter* writer, const gchar* format, ...);
  31. #endif