You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

json_util.h 1.2 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * $Id: json_util.h,v 1.4 2006/01/30 23:07:57 mclark Exp $
  3. *
  4. * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
  5. * Michael Clark <michael@metaparadigm.com>
  6. *
  7. * This library is free software; you can redistribute it and/or modify
  8. * it under the terms of the MIT license. See COPYING for details.
  9. *
  10. */
  11. #ifndef _json_util_h_
  12. #define _json_util_h_
  13. #include "json_object.h"
  14. #ifndef json_min
  15. #define json_min(a,b) ((a) < (b) ? (a) : (b))
  16. #endif
  17. #ifndef json_max
  18. #define json_max(a,b) ((a) > (b) ? (a) : (b))
  19. #endif
  20. #ifdef __cplusplus
  21. extern "C" {
  22. #endif
  23. #define JSON_FILE_BUF_SIZE 4096
  24. /* utility functions */
  25. extern struct json_object* json_object_from_file(const char *filename);
  26. extern struct json_object* json_object_from_fd(int fd);
  27. extern int json_object_to_file(const char *filename, struct json_object *obj);
  28. extern int json_object_to_file_ext(const char *filename, struct json_object *obj, int flags);
  29. extern int json_parse_int64(const char *buf, int64_t *retval);
  30. extern int json_parse_double(const char *buf, double *retval);
  31. /**
  32. * Return a string describing the type of the object.
  33. * e.g. "int", or "object", etc...
  34. */
  35. extern const char *json_type_to_name(enum json_type o_type);
  36. #ifdef __cplusplus
  37. }
  38. #endif
  39. #endif