本文整理汇总了C#中JSONArray.AddJSONObject方法的典型用法代码示例。如果您正苦于以下问题:C# JSONArray.AddJSONObject方法的具体用法?C# JSONArray.AddJSONObject怎么用?C# JSONArray.AddJSONObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JSONArray
的用法示例。
在下文中一共展示了JSONArray.AddJSONObject方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LayersResHandler
private byte[] LayersResHandler(NameValueCollection boundVariables, string outputFormat, string requestProperties, out string responseProperties)
{
responseProperties = "{\"Content-Type\" : \"application/json\"}";
String aoLayerType = "";
if (this.layerType.Equals("feature"))
{
aoLayerType = "Feature Layer";
}
else if (this.layerType.Equals("raster"))
{
aoLayerType = "Raster Layer";
}
else if (this.layerType.Equals("dataset"))
{
aoLayerType = "Network Dataset Layer";
}
else
{
throw new Exception("Propety layerType has invalid value. Acceptable values are \"feature\", \"raster\", and \"dataset\".");
}
JSONArray layersArray = new JSONArray();
for (int i = 0; i < this.layerInfos.Count; i++)
{
IMapLayerInfo layerInfo = layerInfos.get_Element(i);
String lType = layerInfo.Type;
if (lType.Equals(aoLayerType))
{
JSONObject jo = new JSONObject();
jo.AddString("name", layerInfo.Name);
jo.AddLong("id", layerInfo.ID);
jo.AddString("description", layerInfo.Description);
layersArray.AddJSONObject(jo);
}
}
JSONObject result = new JSONObject();
result.AddJSONArray("Layers", layersArray);
return Encoding.UTF8.GetBytes(result.ToJSONString(null));
}
示例2: getLayerInfo
private JSONArray getLayerInfo()
{
JSONArray layersArray = new JSONArray();
for (int i = 0; i < this.layerInfos.Count; i++)
{
IMapLayerInfo layerInfo = layerInfos.get_Element(i);
JSONObject jo = new JSONObject();
jo.AddString("name", layerInfo.Name);
jo.AddLong("id", layerInfo.ID);
jo.AddString("description", layerInfo.Description);
layersArray.AddJSONObject(jo);
}
return layersArray;
}
示例3: LayersResHandler
private byte[] LayersResHandler(NameValueCollection boundVariables, string outputFormat, string requestProperties, out string responseProperties)
{
responseProperties = "{\"Content-Type\" : \"application/json\"}";
JSONArray layersArray = new JSONArray();
for (int i = 0; i < this.layerInfos.Count; i++)
{
IMapLayerInfo layerInfo = layerInfos.get_Element(i);
JSONObject jo = new JSONObject();
jo.AddString("name", layerInfo.Name);
jo.AddLong("id", layerInfo.ID);
jo.AddBoolean("addlayer", false);
jo.AddString("description", layerInfo.Description);
layersArray.AddJSONObject(jo);
}
JSONObject result = new JSONObject();
result.AddJSONArray("layers", layersArray);
return Encoding.UTF8.GetBytes(result.ToJSONString(null));
}