ArrayList ValuesAL;
if (oValuesAL == null)
{
ValuesAL = new ArrayList();
childNodeNames[nodeName] = ValuesAL;
}
else
ValuesAL = (ArrayList)oValuesAL;
ValuesAL.Add(nodeValue);
}
private static void OutputNode(string childname, object alChild, StringBuilder sbJSON, bool showNodeName)
{
if (alChild == null)
{
if (showNodeName)
sbJSON.Append(""" + SafeJSON(childname) + "": ");
sbJSON.Append("null");
}
else if (alChild is string)
{
if (showNodeName)
sbJSON.Append(""" + SafeJSON(childname) + "": ");
string sChild = (string)alChild;
sChild = sChild.Trim();
sbJSON.Append(""" + SafeJSON(sChild) + """);
}
else
XmlToJSONnode(sbJSON, (XmlElement)alChild, showNodeName);
sbJSON.Append(", ");
}
// Make a string safe for JSON
private static string SafeJSON(string sIn)
{
StringBuilder sbOut = new StringBuilder(sIn.Length);
foreach (char ch in sIn)
{
if (Char.IsControl(ch) || ch == ''')
{
int ich = (int)ch;
sbOut.Append(@"u" + ich.ToString("x4"));
continue;
}
else if (ch == '"' || ch == '' || ch == '/')
{
sbOut.Append('');
}








