[mapguide-commits] r8826 - sandbox/jng/clean_json/Web/src/HttpHandler
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Wed Nov 11 05:35:40 PST 2015
Author: jng
Date: 2015-11-11 05:35:40 -0800 (Wed, 11 Nov 2015)
New Revision: 8826
Modified:
sandbox/jng/clean_json/Web/src/HttpHandler/XmlJsonConvert.cpp
Log:
De-arrayify top-level attributes when CLEAN=1 and output format is JSON
Modified: sandbox/jng/clean_json/Web/src/HttpHandler/XmlJsonConvert.cpp
===================================================================
--- sandbox/jng/clean_json/Web/src/HttpHandler/XmlJsonConvert.cpp 2015-11-11 11:17:37 UTC (rev 8825)
+++ sandbox/jng/clean_json/Web/src/HttpHandler/XmlJsonConvert.cpp 2015-11-11 13:35:40 UTC (rev 8826)
@@ -91,10 +91,17 @@
MgUtil::WideCharToMultiByte(X2W(attribute->getNodeName()), nodeName);
MgUtil::WideCharToMultiByte(X2W(attribute->getNodeValue()), nodeValue);
- // Write the attribute as a single array element
- m_jsonDoc.BeginArray(1, "@" + nodeName);
- m_jsonDoc.SetArrayValue(0, nodeValue);
- m_jsonDoc.EndArray();
+ if (bClean)
+ {
+ m_jsonDoc.AddAttribute(nodeName, nodeValue);
+ }
+ else
+ {
+ // Write the attribute as a single array element
+ m_jsonDoc.BeginArray(1, "@" + nodeName);
+ m_jsonDoc.SetArrayValue(0, nodeValue);
+ m_jsonDoc.EndArray();
+ }
}
}
@@ -290,12 +297,14 @@
bool MgXmlJsonConvert::GetElementPath(DOMNode * node, string & path, const XMLCh * suffix)
{
- if (NULL != node) {
+ if (NULL != node)
+ {
STRING elPath = L"/";
elPath += node->getNodeName();
elPath += suffix;
DOMNode* currentNode = node->getParentNode();
- while (NULL != currentNode) {
+ while (NULL != currentNode)
+ {
if (currentNode->getNodeType() == DOMNode::DOCUMENT_NODE) {
STRING pathPart = L"/";
pathPart += currentNode->getNodeName();
@@ -304,7 +313,8 @@
if (NULL == currentNode)
break;
}
- else {
+ else
+ {
break;
}
}
More information about the mapguide-commits
mailing list