[prev in list] [next in list] [prev in thread] [next in thread]
List: mapguide-commits
Subject: [mapguide-commits] r8827 - sandbox/jng/clean_json/Web/src/HttpHandler
From: svn_mapguide () osgeo ! org
Date: 2015-11-11 13:59:25
Message-ID: 20151111135925.5143A39012E () trac ! osgeo ! org
[Download RAW message or body]
Author: jng
Date: 2015-11-11 05:59:25 -0800 (Wed, 11 Nov 2015)
New Revision: 8827
Modified:
sandbox/jng/clean_json/Web/src/HttpHandler/XmlJsonConvert.cpp
Log:
De-arrayify single-cardinality element nodes 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 13:35:40 UTC (rev 8826)
+++ sandbox/jng/clean_json/Web/src/HttpHandler/XmlJsonConvert.cpp 2015-11-11 13:59:25 UTC (rev 8827)
@@ -196,10 +196,17 @@
string textContent;
MgUtil::WideCharToMultiByte(X2W(node->getTextContent()), textContent);
- // Write the text as a single array element
- m_jsonDoc.BeginArray(1, nodeName);
- m_jsonDoc.SetArrayValue(0, textContent);
- m_jsonDoc.EndArray();
+ if (bClean)
+ {
+ m_jsonDoc.AddAttribute(nodeName, textContent);
+ }
+ else
+ {
+ // Write the text as a single array element
+ m_jsonDoc.BeginArray(1, nodeName);
+ m_jsonDoc.SetArrayValue(0, textContent);
+ m_jsonDoc.EndArray();
+ }
return;
}
else if (nodeType == DOMNode::ELEMENT_NODE)
@@ -224,10 +231,17 @@
MgUtil::WideCharToMultiByte(X2W(childNode->getTextContent()), textContent);
if (this->ValidateTextContent(textContent))
{
- // Write the text as a single array element
- m_jsonDoc.BeginArray(1, nodeName);
- m_jsonDoc.SetArrayValue(0, textContent);
- m_jsonDoc.EndArray();
+ if (bClean)
+ {
+ m_jsonDoc.Add(nodeName, textContent);
+ }
+ else
+ {
+ // Write the text as a single array element
+ m_jsonDoc.BeginArray(1, nodeName);
+ m_jsonDoc.SetArrayValue(0, textContent);
+ m_jsonDoc.EndArray();
+ }
}
return;
}
_______________________________________________
mapguide-commits mailing list
mapguide-commits@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapguide-commits
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic