test_float.c 843 B

123456789101112131415161718192021222324
  1. /* Copyright (C) 2016 by Rainer Gerhards
  2. * Released under ASL 2.0 */
  3. #include "config.h"
  4. #include <stdio.h>
  5. #include "../json_object.h"
  6. #include "../json_tokener.h"
  7. int main(void)
  8. {
  9. json_object *json;
  10. json = json_object_new_double(1.0);
  11. printf("json = %s\n", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY));
  12. json_object_put(json);
  13. json = json_object_new_double(1.23);
  14. printf("json = %s\n", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY));
  15. json_object_put(json);
  16. json = json_object_new_double(123456789.0);
  17. printf("json = %s\n", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY));
  18. json_object_put(json);
  19. json = json_object_new_double(123456789.123);
  20. printf("json = %s\n", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY));
  21. json_object_put(json);
  22. return 0;
  23. }