summaryrefslogtreecommitdiffstats
path: root/src/rpc-server/trex_rpc_jsonrpc_v2_parser.cpp
diff options
context:
space:
mode:
authorHanoh Haim <hhaim@cisco.com>2015-09-10 07:54:05 +0300
committerHanoh Haim <hhaim@cisco.com>2015-09-10 07:54:05 +0300
commita360a1734c459d62bd4c204a6005214ce8944f85 (patch)
treee06cad6cf63a52701aff303c19024cde1d541ebd /src/rpc-server/trex_rpc_jsonrpc_v2_parser.cpp
parent15b4f7cd7c3e9176c1f24fc632791e833cb588b8 (diff)
parente33befcf222fd2108d589dede11069d4256bb21a (diff)
Merge branch 'master' of csi-sceasr-b45:/auto/proj-pcube-b/apps/PL-b/tools/repo//trex-core
Conflicts: linux/ws_main.py
Diffstat (limited to 'src/rpc-server/trex_rpc_jsonrpc_v2_parser.cpp')
-rw-r--r--src/rpc-server/trex_rpc_jsonrpc_v2_parser.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/rpc-server/trex_rpc_jsonrpc_v2_parser.cpp b/src/rpc-server/trex_rpc_jsonrpc_v2_parser.cpp
index 3831bb37..928baca6 100644
--- a/src/rpc-server/trex_rpc_jsonrpc_v2_parser.cpp
+++ b/src/rpc-server/trex_rpc_jsonrpc_v2_parser.cpp
@@ -200,3 +200,28 @@ void TrexJsonRpcV2Parser::parse_single_request(Json::Value &request,
commands.push_back(new JsonRpcMethod(msg_id, rpc_cmd, request["params"]));
}
+/**
+ * tries to pretty a JSON str
+ *
+ * @author imarom (03-Sep-15)
+ *
+ * @param json_str
+ *
+ * @return std::string
+ */
+std::string TrexJsonRpcV2Parser::pretty_json_str(const std::string &json_str) {
+ Json::Reader reader;
+ Json::Value value;
+
+ /* basic JSON parsing */
+ bool rc = reader.parse(json_str, value, false);
+ if (!rc) {
+ /* duplicate the soruce */
+ return json_str;
+ }
+
+ /* successfully parsed */
+ Json::StyledWriter writer;
+ return writer.write(value);
+}
+