Skip to content

Commit

Permalink
JsonGetKeys
Browse files Browse the repository at this point in the history
  • Loading branch information
zhouhang95 committed Oct 29, 2024
1 parent 9b71388 commit f367bf6
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion zeno/src/nodes/JsonProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include <tinygltf/json.hpp>
#include <zeno/zeno.h>

using Json = nlohmann::json;
using Json = nlohmann::ordered_json;

namespace zeno {
struct JsonObject : IObjectClone<JsonObject> {
Expand Down Expand Up @@ -415,6 +415,29 @@ ZENDEFNODE(JsonGetString, {
"deprecated"
},
});

struct JsonGetKeys : zeno::INode {
virtual void apply() override {
auto json = get_input<JsonObject>("json");
auto list = std::make_shared<ListObject>();
for (auto& [key, _] : json->json.items()) {
list->arr.emplace_back(std::make_shared<zeno::StringObject>(key));
}
set_output2("keys", list);
}
};
ZENDEFNODE(JsonGetKeys, {
{
{"json"},
},
{
"keys",
},
{},
{
"json"
},
});
struct JsonGetTypeName : zeno::INode {
virtual void apply() override {
auto json = get_input<JsonObject>("json");
Expand Down

0 comments on commit f367bf6

Please sign in to comment.