Work with JSON in a REST SOE
private byte[] SampleOperHandler(NameValueCollection boundVariables, JsonObject operationInput, string outputFormat, string requestProperties, out string responseProperties) { responseProperties = null; string parm1Value; bool found = operationInput.TryGetString("parm1", out parm1Value); if (!found || string.IsNullOrEmpty(parm1Value)) throw new ArgumentNullException("parm1"); ... }
参考:https://developers.arcgis.com/enterprise-sdk/guide/net/work-with-json-in-a-rest-soe-net/
// Create an empty .NET list of JsonObjects. List < JsonObject > jsonGeometries = new List < JsonObject > (); // Optionally, you could start a loop here. JsonObject jsonResultsGeometry = Conversion.ToJsonObject(resultsGeometry); jsonGeometries.Add(jsonResultsGeometry); // You would end the optional loop here. // Add the list of json objects to a final json object as an array. JsonObject resultJsonObject = new JsonObject(); resultJsonObject.AddArray("geometries", jsonGeometries.ToArray()); // Get byte array of json and return results. byte[] result = Encoding.UTF8.GetBytes(resultJsonObject.ToJson()); return result;
浏览器端接收到数据之后,可以进行解析。