当前位置: 首页>>代码示例>>C#>>正文


C# JSONObject.ToJSONString方法代码示例

本文整理汇总了C#中JSONObject.ToJSONString方法的典型用法代码示例。如果您正苦于以下问题:C# JSONObject.ToJSONString方法的具体用法?C# JSONObject.ToJSONString怎么用?C# JSONObject.ToJSONString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JSONObject的用法示例。


在下文中一共展示了JSONObject.ToJSONString方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: createErrorObject

        private byte[] createErrorObject(int codeNumber, String errorMessageSummary, String[] errorMessageDetails)
        {
            if (errorMessageSummary.Length == 0 || errorMessageSummary == null)
            {
                throw new Exception("Invalid error message specified.");
            }

            JSONObject errorJSON = new JSONObject();
            errorJSON.AddLong("code", codeNumber);
            errorJSON.AddString("message", errorMessageSummary);

            if (errorMessageDetails == null)
            {
                errorJSON.AddString("details", "No error details specified.");
            }
            else
            {
                String errorMessages = "";
                for (int i = 0; i < errorMessageDetails.Length; i++)
                {
                    errorMessages = errorMessages + errorMessageDetails[i] + "\n";
                }

                errorJSON.AddString("details", errorMessages);
            }

            JSONObject error = new JSONObject();
            error.AddJSONObject("error", errorJSON);

            return Encoding.UTF8.GetBytes(error.ToJSONString(null));
        }
开发者ID:Esri,项目名称:arcobjects-sdk-community-samples,代码行数:31,代码来源:NetEditFeaturesRESTSOE.cs

示例2: RootResHandler

        private byte[] RootResHandler(NameValueCollection boundVariables, string outputFormat, string requestProperties, out string responseProperties)
        {
            responseProperties = null;

            JSONObject json = new JSONObject();
            json.AddString("name", ".NET Simple REST SOE With Capabilities");
            json.AddJSONArray("layerInfo", getLayerInfo());

            return Encoding.UTF8.GetBytes(json.ToJSONString(null));
        }
开发者ID:Esri,项目名称:arcobjects-sdk-community-samples,代码行数:10,代码来源:NetSimpleRESTSOEWithCapabilities.cs

示例3: RootResHandler

        private byte[] RootResHandler(NameValueCollection boundVariables, string outputFormat, string requestProperties, out string responseProperties)
        {
            responseProperties = null;

            JSONObject result = new JSONObject();
            result.AddString("name", ".Net Simple REST SOE With properties");
            result.AddString("description", "Simple REST SOE with 1 sub-resource called \"layers\" and 1 property called layerType.");
            result.AddString("usage", "The \"layers\" subresource returns all layers of a certain type in the map service.\n"
                + "The layerType property defines the type of layers are returned by the \"layers\" subresource."); 

            return Encoding.UTF8.GetBytes(result.ToJSONString(null));
        }
开发者ID:Esri,项目名称:arcobjects-sdk-community-samples,代码行数:12,代码来源:NetSimpleRESTSOEWithProperties.cs

示例4: 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));
        }
开发者ID:Esri,项目名称:arcobjects-sdk-community-samples,代码行数:40,代码来源:NetSimpleRESTSOEWithProperties.cs

示例5: getLayerCountByType

        private byte[] getLayerCountByType(System.Collections.Specialized.NameValueCollection boundVariables,
            ESRI.ArcGIS.SOESupport.JsonObject operationInput,
            string outputFormat,
            string requestProperties,
            out string responseProperties) 
        {
            IMapImage mapImage = null;

            bool? shouldAdd = null;
            operationInput.TryGetAsBoolean("addlayer", out shouldAdd);

            if (shouldAdd.HasValue)
            {
                if ((bool)shouldAdd)
                {
                    if (((IMapServerInfo4)mapServerInfo).SupportsDynamicLayers)
                    {
                        IRgbColor color = new RgbColor(){ Blue = 255};

                        ISimpleLineSymbol outline = new SimpleLineSymbol(){ 
                            Color = color, 
                            Width = 1, 
                            Style = esriSimpleLineStyle.esriSLSSolid
                        };

                        ISimpleFillSymbol sfs = new SimpleFillSymbol(){ 
                            Color = color, 
                            Outline = outline, 
                            Style = esriSimpleFillStyle.esriSFSSolid
                        };
                        
                        ISimpleRenderer sr = new SimpleRenderer(){ Symbol = (ISymbol)sfs };

                        IFeatureLayerDrawingDescription featureLayerDrawingDesc = new FeatureLayerDrawingDescription(){
                            FeatureRenderer = (IFeatureRenderer)sr
                        };

                        IMapServerSourceDescription mapServerSourceDesc = new TableDataSourceDescriptionClass();
                        ((IDataSourceDescription)mapServerSourceDesc).WorkspaceID = "MyFGDB";
                        ((ITableDataSourceDescription)mapServerSourceDesc).TableName = "B";

                        IDynamicLayerDescription dynamicLayerDesc = new LayerDescriptionClass(){
                            ID = 3,
                            Visible = true,
                            DrawingDescription = (ILayerDrawingDescription)featureLayerDrawingDesc,
                            Source = mapServerSourceDesc
                        };

                        mapDesc.HonorLayerReordering = true;
                        mapDesc.LayerDescriptions.Insert(0, (ILayerDescription)dynamicLayerDesc);

                        mapImage = exportMap();
                    }    
                }
                else
                {
                    mapImage = exportMap();
                }
            }
            responseProperties = null; 
  
        	JSONObject json = new JSONObject();
            json.AddString("URL", mapImage.URL);
            return Encoding.UTF8.GetBytes(json.ToJSONString(null));
        }
开发者ID:ApexGIS,项目名称:developer-support,代码行数:65,代码来源:NetSimpleRESTSOE.cs

示例6: 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));
        }
开发者ID:ApexGIS,项目名称:developer-support,代码行数:21,代码来源:NetSimpleRESTSOE.cs

示例7: RootResHandler

        private byte[] RootResHandler(System.Collections.Specialized.NameValueCollection boundVariables,
            string outputFormat,
            string requestProperties,
            out string responseProperties)
        {
            responseProperties = null; 
    
            JSONObject json = new JSONObject();
	        json.AddString("name", ".Net Simple REST SOE");
	        json.AddString("description", "Simple REST SOE with 1 sub-resource called \"layers\" and 1 operation called \"getLayerCountByType\".");
	        json.AddString("usage", "The \"layers\" subresource returns all layers in the map service.\n"
			    + "The \"getLayerCountByType\" operation returns a count of layer of specified type. It accepts one of the following values as input: \"feature\", \"raster\", "
			    + "\"dataset\", and \"all\".");
	        return Encoding.UTF8.GetBytes(json.ToJSONString(null));
        }
开发者ID:ApexGIS,项目名称:developer-support,代码行数:15,代码来源:NetSimpleRESTSOE.cs

示例8: GetRendererFromLayer

        /// <summary>
        /// Extracts renderer information from a layer resource
        /// </summary>
        /// <param name="layerResource">json representation of layer</param>
        /// <returns></returns>
        public static string GetRendererFromLayer(String layerResource)
        {
            String jsonRenderer = "";
            IJSONObject jObject = new JSONObject();
            jObject.ParseString(layerResource);

            IJSONObject joDrawingInfo = new JSONObject();
            jObject.TryGetValueAsObject("drawingInfo", out joDrawingInfo);

            //if no drawingInfo found, say for group layers
            if (joDrawingInfo == null)
                return jsonRenderer;

            jsonRenderer = joDrawingInfo.ToJSONString(null);
            return jsonRenderer;
        }
开发者ID:ApexGIS,项目名称:developer-support,代码行数:21,代码来源:Utils.cs

示例9: getLayerCountByType

        private byte[] getLayerCountByType(System.Collections.Specialized.NameValueCollection boundVariables,
            ESRI.ArcGIS.SOESupport.JsonObject operationInput,
            string outputFormat,
            string requestProperties,
            out string responseProperties)
        {
            responseProperties = null;

            String layerType = "";
            operationInput.TryGetString("type", out layerType);

            JSONObject json = new JSONObject();

            int count = 0;
            if (layerType != null && layerType.Length > 0)
            {
                String aoType = "";
                if (layerType.Equals("all"))
                {
                    count = layerInfos.Count;
                }
                else if (layerType.Equals("feature"))
                {
                    aoType = "Feature Layer";
                }
                else if (layerType.Equals("raster"))
                {
                    aoType = "Raster Layer";
                }
                else if (layerType.Equals("dataset"))
                {
                    aoType = "Network Dataset Layer";
                }

                for (int i = 0; i < layerInfos.Count; i++)
                {
                    if (layerInfos.get_Element(i).Type.Equals(aoType))
                    {
                        count++;
                    }
                }

                json.AddLong("count", count);

                return Encoding.UTF8.GetBytes(json.ToJSONString(null));
            }
            else
            {
                return createErrorObject(500, "Invalid layer type provided. Available types are: \"all\", \"feature\", \"raster\", \"dataset\".",
                    new String[1] { "No details specified." });
            }
        }
开发者ID:Esri,项目名称:arcobjects-sdk-community-samples,代码行数:52,代码来源:NetSimpleRESTSOE.cs


注:本文中的JSONObject.ToJSONString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。