JSON Dialplan Support

Jul 24, 2014 at 11:14 AM
I want to gather thoughts for adding a new method to the dialplan facades to allow JSON data parsing.

The idea is this will allow dialplans to access remote data much easier. It would be coupled with WebGet.

So, what do people think generally to the idea. What would the return object be? Something like JObject found in Newtonsoft's JSON implementation?

Example usage:
data = sys.JSONToObject(sys.WebGet(url))
someValue = data.SelectToken("someValue").Value
I look forwards to thoughts and comments.
Jul 24, 2014 at 11:34 AM
A simple implementation might look like.
        /// <summary>
        /// Returns a Dynamic object parsed from a JSon string
        /// </summary>
        /// <param name="json"></param>
        /// <returns></returns>
        public dynamic JSonToObject(string json)
                dynamic rtn = JsonConvert.DeserializeObject<dynamic>(json);
                return rtn;
                return null;
Jul 24, 2014 at 12:14 PM
At one stage in the past we did use the Ruby json gem.
require 'json'

myJSON = '{"firstName": "John", "lastName": "Smith"}'
jsonOBJ = JSON.parse(myJSON)
sys.Log("#{jsonOBJ['firstName']} #{jsonOBJ['lastName']}")
I can't remember why I took that gem away but probably it was an oversight as part of a server move or something. I could see about re-enabling it if that would fill the need.