From 065dd50ce7d9ea80d18fecbc2857da1d05a71b9a Mon Sep 17 00:00:00 2001 From: vanhofen Date: Tue, 23 Feb 2016 14:24:19 +0100 Subject: [PATCH] yhook: allow multiple json objects Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/e89d0433ad77497450f1213ef2aba86b7a365197 Author: vanhofen Date: 2016-02-23 (Tue, 23 Feb 2016) Origin message was: ------------------ - yhook: allow multiple json objects --- src/nhttpd/yhttpd_core/yhook.cpp | 4 +++- src/nhttpd/yhttpd_core/yhook.h | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/nhttpd/yhttpd_core/yhook.cpp b/src/nhttpd/yhttpd_core/yhook.cpp index 15c2aef5e..82158f89c 100644 --- a/src/nhttpd/yhttpd_core/yhook.cpp +++ b/src/nhttpd/yhttpd_core/yhook.cpp @@ -495,7 +495,7 @@ std::string CyhookHandler::outArrayItem(std::string _key, std::string _content, return result; } //----------------------------------------------------------------------------- -std::string CyhookHandler::outCollection(std::string _key, std::string _content) { +std::string CyhookHandler::outCollection(std::string _key, std::string _content, bool _next) { std::string result = ""; switch (outType) { case xml: @@ -506,6 +506,8 @@ std::string CyhookHandler::outCollection(std::string _key, std::string _content) case json: //TODO: json check result = outIndent() + "\"" + _key + "\": {" + _content + "}"; + if(_next) + result += ","; result += "\n"; break; default: diff --git a/src/nhttpd/yhttpd_core/yhook.h b/src/nhttpd/yhttpd_core/yhook.h index 096deaef0..64016d325 100644 --- a/src/nhttpd/yhttpd_core/yhook.h +++ b/src/nhttpd/yhttpd_core/yhook.h @@ -208,7 +208,7 @@ public: std::string outPair(std::string _key, std::string _content, bool _next); std::string outArray(std::string _key, std::string _content); std::string outArrayItem(std::string _key, std::string _content, bool _next); - std::string outCollection(std::string _key,std::string _content); + std::string outCollection(std::string _key,std::string _content, bool _next = false); std::string outValue(std::string _content); std::string outNext(); friend class CyParser;