Download gemma.cpp/build/_deps/json-src/docs/examples/README.cpp from ZeroWw/gemma-2-9b-SBS: direct link, hf CLI and curl.
- Browser
- Download file 753 Bytes
-
https://huggingface.co/ZeroWw/gemma-2-9b-SBS/resolve/main/gemma.cpp/build/_deps/json-src/docs/examples/README.cpp
- Command line
-
hf download hf://ZeroWw/gemma-2-9b-SBS/gemma.cpp/build/_deps/json-src/docs/examples/README.cpp
-
curl -L -o README.cpp https://huggingface.co/ZeroWw/gemma-2-9b-SBS/resolve/main/gemma.cpp/build/_deps/json-src/docs/examples/README.cpp
753 Bytes
| using json = nlohmann::json; | |
| int main() | |
| { | |
| // create a JSON object | |
| json j = | |
| { | |
| {"pi", 3.141}, | |
| {"happy", true}, | |
| {"name", "Niels"}, | |
| {"nothing", nullptr}, | |
| { | |
| "answer", { | |
| {"everything", 42} | |
| } | |
| }, | |
| {"list", {1, 0, 2}}, | |
| { | |
| "object", { | |
| {"currency", "USD"}, | |
| {"value", 42.99} | |
| } | |
| } | |
| }; | |
| // add new values | |
| j["new"]["key"]["value"] = {"another", "list"}; | |
| // count elements | |
| auto s = j.size(); | |
| j["size"] = s; | |
| // pretty print with indent of 4 spaces | |
| std::cout << std::setw(4) << j << '\n'; | |
| } | |