public void SerializeList(object vList,bool BuildValue, bool BuildString) { //Note: _value and _jsonString have already been cleared string s="["; iesJSON j2; int cnt=0; if (BuildValue) { _value=new System.Collections.Generic.List<Object>(); _value_valid=true; _jsonType="array"; } foreach (object v in (System.Collections.Generic.List<Object>)vList) { j2=new iesJSON(); j2.UseFlexJson=UseFlexJson; j2.ALLOW_SINGLE_QUOTE_STRINGS=ALLOW_SINGLE_QUOTE_STRINGS; object v2=v; j2.Serialize(v2,BuildValue,BuildString); if (j2.Status==0) { if (BuildString) { if (cnt>0) { s=s + ","; } s=s + j2.jsonString; } if (BuildValue) { j2.Parent=this; ((System.Collections.Generic.List<Object>)_value).Add(j2); } cnt=cnt+1; } else { // *** raise error! StatusErr(-94,"Failed to serialize object @ " + cnt + " (e-94) [" + j2.StatusMessage + "]"); break; } } //Next s=s + "]"; if (BuildString) { _jsonString=s; _jsonString_valid=true; } }
public void SerializeCollectionKeys(object vList,bool BuildValue,bool BuildString) { //Note: _value and _jsonString have already been cleared string s="{",t; iesJSON j2; int cnt=0; bool fProcessed=false; if (BuildValue) { _value=new System.Collections.Generic.List<Object>(); _value_valid=true; _jsonType="object"; } if (vList==null) { return; } //Return with an empty object t=GetObjType(vList); // *************************************** DICTIONARY if (t.IndexOf("dictionary")>=0) { fProcessed=true; System.Collections.Generic.Dictionary<string,object> vList2=(System.Collections.Generic.Dictionary<string,object>) vList; //System.Collections.ObjectModel.Collection<object> vList2=(System.Collections.ObjectModel.Collection<object>) vList; foreach ( System.Collections.Generic.KeyValuePair<string, object> kvp in vList2 ) { string v=kvp.Key; object o=kvp.Value; j2=new iesJSON(); j2.UseFlexJson=UseFlexJson; j2.ALLOW_SINGLE_QUOTE_STRINGS=ALLOW_SINGLE_QUOTE_STRINGS; j2.Serialize(o,BuildValue,BuildString); j2.Key=v; if (j2.Status==0) { if (BuildString) { if (cnt>0) { s=s + ","; } s=s + "\"" + v + "\":" + j2.jsonString; } if (BuildValue) { j2.Parent=this; ((System.Collections.Generic.List<Object>)_value).Add(j2); } cnt=cnt+1; } else { // *** raise error! StatusErr(-93,"Failed to serialize collection key @ " + cnt + " key=" + v + " (e-93) [" + j2.StatusMessage + "]"); break; } } // Next } // *************************************** HTML FORM RESPONSE if (t.IndexOf("http")>=0) { fProcessed=true; //System.Collections.Generic.Dictionary<string,object> vList2=(System.Collections.Generic.Dictionary<string,object>) vList; //System.Collections.ObjectModel.Collection<object> vList2=(System.Collections.ObjectModel.Collection<object>) vList; System.Collections.Specialized.NameValueCollection vList2 = (System.Collections.Specialized.NameValueCollection)vList; foreach (string v in vList2) { object o = vList2[v]; j2=new iesJSON(); j2.UseFlexJson=UseFlexJson; j2.ALLOW_SINGLE_QUOTE_STRINGS=ALLOW_SINGLE_QUOTE_STRINGS; j2.Serialize(o,BuildValue,BuildString); j2.Key=v; if (j2.Status==0) { if (BuildString) { if (cnt>0) { s=s + ","; } s=s + "\"" + v + "\":" + j2.jsonString; } if (BuildValue) { j2.Parent=this; ((System.Collections.Generic.List<Object>)_value).Add(j2); } cnt=cnt+1; } else { // *** raise error! StatusErr(-93,"Failed to serialize collection key @ " + cnt + " key=" + v + " (e-93) [" + j2.StatusMessage + "]"); break; } } // Next } if (fProcessed==false) { _status=-87; AddStatusMessage("ERROR: Failed to process collection. Type not valid: '" + t + "' [err-87]"); } s=s + "}"; if (BuildString) { _jsonString=s; _jsonString_valid=true; } }