CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
60 lines
1.3 KiB
C++
60 lines
1.3 KiB
C++
#include <iostream>
|
|
#include <unordered_map>
|
|
#include <nlohmann/json.hpp>
|
|
|
|
using json = nlohmann::json;
|
|
|
|
int main()
|
|
{
|
|
// create a JSON value with different types
|
|
json json_types =
|
|
{
|
|
{"boolean", true},
|
|
{
|
|
"number", {
|
|
{"integer", 42},
|
|
{"floating-point", 17.23}
|
|
}
|
|
},
|
|
{"string", "Hello, world!"},
|
|
{"array", {1, 2, 3, 4, 5}},
|
|
{"null", nullptr}
|
|
};
|
|
|
|
bool v1;
|
|
int v2;
|
|
short v3;
|
|
float v4;
|
|
int v5;
|
|
std::string v6;
|
|
std::vector<short> v7;
|
|
std::unordered_map<std::string, json> v8;
|
|
|
|
// use explicit conversions
|
|
json_types["boolean"].get_to(v1);
|
|
json_types["number"]["integer"].get_to(v2);
|
|
json_types["number"]["integer"].get_to(v3);
|
|
json_types["number"]["floating-point"].get_to(v4);
|
|
json_types["number"]["floating-point"].get_to(v5);
|
|
json_types["string"].get_to(v6);
|
|
json_types["array"].get_to(v7);
|
|
json_types.get_to(v8);
|
|
|
|
// print the conversion results
|
|
std::cout << v1 << '\n';
|
|
std::cout << v2 << ' ' << v3 << '\n';
|
|
std::cout << v4 << ' ' << v5 << '\n';
|
|
std::cout << v6 << '\n';
|
|
|
|
for (auto i : v7)
|
|
{
|
|
std::cout << i << ' ';
|
|
}
|
|
std::cout << "\n\n";
|
|
|
|
for (auto i : v8)
|
|
{
|
|
std::cout << i.first << ": " << i.second << '\n';
|
|
}
|
|
}
|