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

23 lines
798 B

  1. #include <json.hpp>
  2. using json = nlohmann::json;
  3. int main()
  4. {
  5. // create several JSON values
  6. json array_1 = {1, 2, 3};
  7. json array_2 = {1, 2, 4};
  8. json object_1 = {{"A", "a"}, {"B", "b"}};
  9. json object_2 = {{"B", "b"}, {"A", "a"}};
  10. json number_1 = 17;
  11. json number_2 = 17.000000000000001L;
  12. json string_1 = "foo";
  13. json string_2 = "bar";
  14. // output values and comparisons
  15. std::cout << std::boolalpha;
  16. std::cout << array_1 << " == " << array_2 << " " << (array_1 == array_2) << '\n';
  17. std::cout << object_1 << " == " << object_2 << " " << (object_1 == object_2) << '\n';
  18. std::cout << number_1 << " == " << number_2 << " " << (number_1 == number_2) << '\n';
  19. std::cout << string_1 << " == " << string_2 << " " << (string_1 == string_2) << '\n';
  20. }