Skip to content

Commit

Permalink
Fixed issue CiscoDevNet#1089
Browse files Browse the repository at this point in the history
  • Loading branch information
ygorelik committed Sep 7, 2023
1 parent 35dd61a commit 62df8ce
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 11 deletions.
16 changes: 8 additions & 8 deletions sdk/cpp/core/src/path/root_schema_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@ using json = nlohmann::json;
{
for (json::iterator it = o.begin(); it != o.end(); ++it)
{
// extract module name from key
auto identifier = std::string(it.key());
auto found = identifier.find(":");
if (found != std::string::npos && found > 0)
{
module_names.insert(identifier.substr(0, found));
}
if (it->is_array())
{
for (auto i = it->begin(); i != it->end(); i++)
Expand All @@ -95,14 +102,7 @@ using json = nlohmann::json;
}
else
{
// extract module name from key
auto identifier = std::string(it.key());
auto found = identifier.find(":");
if (found != std::string::npos && found > 0)
{
module_names.insert(identifier.substr(0, found));
}
// extract module name from primitive type value
// extract module name from value
if (it->is_primitive())
{
auto v = it->dump();
Expand Down
25 changes: 22 additions & 3 deletions sdk/cpp/tests/test_sanity_codec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -661,11 +661,30 @@ TEST_CASE("test_codec_decode_augment_json")
CodecServiceProvider codec_provider{EncodingFormat::JSON};
CodecService codec_service{};

auto payload = R"({"ydktest-sanity:passive":{"interfac":[{"test":"abc"}],"name":"xyz","ydktest-sanity-augm:testc":{"xyz":{"xyz":25}}}})";
auto payload = R"({
"ydktest-sanity:runner": {
"passive": [
{
"name": "xyz",
"interfac": [
{
"test": "abc"
}
],
"ydktest-sanity-augm:testc": {
"xyz": {
"xyz": 25
}
}
}
]
}
}
)";

auto entity = codec_service.decode(codec_provider, payload, make_shared<ydktest_sanity::Runner::Passive>());
auto entity = codec_service.decode(codec_provider, payload, make_shared<ydktest_sanity::Runner>());

auto json = codec_service.encode(codec_provider, *entity, false);
auto json = codec_service.encode(codec_provider, *entity, true);
CHECK(payload == json);
}

Expand Down

0 comments on commit 62df8ce

Please sign in to comment.