[Freeswitch-users] JSON-based API calls

Michael Jerris mike at jerris.com
Sat Aug 29 11:02:16 MSD 2015


The architecture is in place for json commands just only a few are
implemented currently

On Friday, August 28, 2015, David McNab <davidmcnabnz at gmail.com> wrote:

> Hi Seven,
>
> What you're suggesting makes consummate sense. I feel a move away from the
> existing single-string input and output for API calls (which imposes an
> encoding/parsing burden on clients) to JSON would slash the cost of
> interfacing to Freeswitch, and further broaden its appeal.
>
> I started writing a higher-level Python interface layer, got as far as
> abstracting the ESL connection and implementing a wrap of the "show calls"
> function, a showCalls() method which actually returns a list of dicts
> rather than an amorphous blob, and thought there has to be a better way.
> Especially since (a) The text output format may change at any time, and (b)
> the same effort would need to be repeated for several different languages.
>
> Is the move to json something that can be done incrementally, one function
> at a time, or does it really need an architectural change? What are
> people's thoughts on the best way of achieving this?
>
> Cheers
> David
>
>
> On 29 August 2015 at 11:55, Seven Du <dujinfang at gmail.com
> <javascript:_e(%7B%7D,'cvml','dujinfang at gmail.com');>> wrote:
>
>> I'd like to start the migration in the following way:
>>
>> 1) write a JSON version of all existing APIs
>> 2) refactor all normal APIs to use JSON API internally and still output
>> the same text result as before
>> 3) It would be easy support other formats like XML and web once all APIs
>> are internally JSON
>> 4) Use modern way to require a desired format like use "Accept" header in
>> HTTP to chose JSON/XML/Text etc.
>>
>> I would experiment a bit if the idea sounds good.
>>
>>
>> On Thu, Aug 27, 2015 at 11:36 PM, Michael Jerris <mike at jerris.com
>> <javascript:_e(%7B%7D,'cvml','mike at jerris.com');>> wrote:
>>
>>> we have added the jsonapi interface but almost nothing uses it yet.
>>> Migrating functions to it will be a project over time
>>>
>>>
>>> On Wednesday, August 26, 2015, David McNab <davidmcnabnz at gmail.com
>>> <javascript:_e(%7B%7D,'cvml','davidmcnabnz at gmail.com');>> wrote:
>>>
>>>> Hi there,
>>>>
>>>> How do you do API calls in JSON? Or, how do I get a list of all the API
>>>> calls which can receive JSON parameters and return JSON return values?
>>>>
>>>> For example, in the console, I tried 'show calls', and got a list of
>>>> calls. I did the same call from via XML-RPC from a python script, and got a
>>>> single string back, containing what would have been output to the console.
>>>> But when I tried, from the console:
>>>>
>>>> *json {"command":"show calls", "format":"pretty", "data":{}}*
>>>>
>>>> I got an invalid response.
>>>>
>>>> I also tried:
>>>>
>>>> *json {"command":"show", "format":"pretty", "data":"calls"}*
>>>>
>>>> but got similar.
>>>>
>>>> Is there a general sceme for invoking all the console API commands (and
>>>> receiving responses) in JSON format?
>>>>
>>>> If not, I guess I need to write some parsers to process each command's
>>>> output string.
>>>>
>>>> Cheers
>>>> David
>>>>
>>>>
>>> _________________________________________________________________________
>>> Professional FreeSWITCH Consulting Services:
>>> consulting at freeswitch.org
>>> <javascript:_e(%7B%7D,'cvml','consulting at freeswitch.org');>
>>> http://www.freeswitchsolutions.com
>>>
>>> Official FreeSWITCH Sites
>>> http://www.freeswitch.org
>>> http://confluence.freeswitch.org
>>> http://www.cluecon.com
>>>
>>> FreeSWITCH-users mailing list
>>> FreeSWITCH-users at lists.freeswitch.org
>>> <javascript:_e(%7B%7D,'cvml','FreeSWITCH-users at lists.freeswitch.org');>
>>> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
>>> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
>>> http://www.freeswitch.org
>>>
>>
>>
>>
>> --
>> About: http://about.me/dujinfang
>> Blog: http://www.dujinfang.com
>> Proj:  http://www.freeswitch.org.cn
>>
>> _________________________________________________________________________
>> Professional FreeSWITCH Consulting Services:
>> consulting at freeswitch.org
>> <javascript:_e(%7B%7D,'cvml','consulting at freeswitch.org');>
>> http://www.freeswitchsolutions.com
>>
>> Official FreeSWITCH Sites
>> http://www.freeswitch.org
>> http://confluence.freeswitch.org
>> http://www.cluecon.com
>>
>> FreeSWITCH-users mailing list
>> FreeSWITCH-users at lists.freeswitch.org
>> <javascript:_e(%7B%7D,'cvml','FreeSWITCH-users at lists.freeswitch.org');>
>> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
>> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
>> http://www.freeswitch.org
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20150829/040ce4c9/attachment.html 


Join us at ClueCon 2016 Aug 8-12, 2016
More information about the FreeSWITCH-users mailing list