From 5d49baccbfb89bea055db54ba664bb06ce955a2a Mon Sep 17 00:00:00 2001 From: emeric Date: Fri, 6 Oct 2023 18:04:16 +0200 Subject: [PATCH] Subsonic API: handle xml for new fields --- src/libs/subsonic/impl/SubsonicResponse.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/libs/subsonic/impl/SubsonicResponse.cpp b/src/libs/subsonic/impl/SubsonicResponse.cpp index 51101396..c210c117 100644 --- a/src/libs/subsonic/impl/SubsonicResponse.cpp +++ b/src/libs/subsonic/impl/SubsonicResponse.cpp @@ -209,23 +209,29 @@ namespace API::Subsonic res.put_value(std::get(value)); else if (std::holds_alternative(value)) res.put_value(std::get(value)); + else if (std::holds_alternative(value)) + res.put_value(std::get(value)); else if (std::holds_alternative(value)) res.put_value(std::get(value)); } else { - for (auto itChildNode : node._children) + for (const auto& [key, childNodes] : node._children) { - for (const Response::Node& childNode : itChildNode.second) - res.add_child(itChildNode.first, nodeToPropertyTree(childNode)); + for (const Response::Node& childNode : childNodes) + res.add_child(key, nodeToPropertyTree(childNode)); } - for (auto itChildArrayNode : node._childrenArrays) + for (const auto& [key, childArrayNodes] : node._childrenArrays) { - const std::vector& childArrayNodes{ itChildArrayNode.second }; - for (const Response::Node& childNode : childArrayNodes) - res.add_child(itChildArrayNode.first, nodeToPropertyTree(childNode)); + res.add_child(key, nodeToPropertyTree(childNode)); + } + + for (const auto& [key, childArrayValues] : node._childrenValues) + { + for (const std::string& value : childArrayValues) + res.add_child(key, boost::property_tree::ptree{ value }); } }