JSON feed from third party
JSON feed from third party
Hi Allan,
I receive a JSON feed of phone call logs from our telephony provider.
The feed is in name/value pairs and looks like this :
[code]
[{"id":9429993,"i_account":1985,"i_customer":654,"CallRecordingAvailable":true,"MP3RecordingAvailable":true,"Withheld":false,"Transfered":false,"CLD":"441534750520","CLI":"441452841172","Note":"","AccountID":"441452841172","call_id":"22e287138510393165980k61855rmwp","SessionID":null,"Direction":"outbound","LastCallStatus":"","CallRecordingURL":"https://api.synety.com/accounts/441452841172/calls/9429993/recordingurl?auth=f0833e607efe693b69e040ce12aac467&expiryDate=2014-03-22T16:25:20","CallRecordingHash":"f0833e607efe693b69e040ce12aac467","ConnectTime":"2013-09-16T12:20:15","DisconnectTime":"2013-09-16T12:20:34","LastUpdated":"2013-09-16T12:20:58Z","ExpiryTime":"2014-03-22T16:25:20.4147735+00:00","TransferTime":null,"ChargedAmount":0.01000,"ChargedTime":0,"CategoryID":null,"ContactID":null,"Category":null,"Contact":null,"CallStatus":null,"ForwardedCalls":null},{"id":8985051,"i_account":1985,"i_customer":654,"CallRecordingAvailable":true,"MP3RecordingAvailable":true,"Withheld":false,"Transfered":false,"CLD":"441534750520","CLI":"441452841172","Note":"","AccountID":"441452841172","call_id":"34e8901526185916939323k65950rmwp","SessionID":null,"Direction":"outbound","LastCallStatus":"","CallRecordingURL":"https://api.synety.com/accounts/441452841172/calls/8985051/recordingurl?auth=221c43cba757a5599d721baa6b56c9e6&expiryDate=2014-03-22T16:25:20","CallRecordingHash":"221c43cba757a5599d721baa6b56c9e6","ConnectTime":"2013-09-06T13:38:29","DisconnectTime":"2013-09-06T13:38:47","LastUpdated":"2013-09-06T13:39:30Z","ExpiryTime":"2014-03-22T16:25:20.4147735+00:00","TransferTime":null,"ChargedAmount":0.01000,"ChargedTime":0,"CategoryID":null,"ContactID":null,"Category":null,"Contact":null,"CallStatus":null,"ForwardedCalls":null}]
[/code]
Previously my code has searched and replaced the name part of the name value pairs to produce a value array that datatables understands. However the provider keeps changing the order of the fields in the feed and when I complain, tells me "JSON is an unordered set of name value pairs", to which I responded "It doesn't have to be!".
Anyway, any idea how I can cope with the random field positions?
I receive a JSON feed of phone call logs from our telephony provider.
The feed is in name/value pairs and looks like this :
[code]
[{"id":9429993,"i_account":1985,"i_customer":654,"CallRecordingAvailable":true,"MP3RecordingAvailable":true,"Withheld":false,"Transfered":false,"CLD":"441534750520","CLI":"441452841172","Note":"","AccountID":"441452841172","call_id":"22e287138510393165980k61855rmwp","SessionID":null,"Direction":"outbound","LastCallStatus":"","CallRecordingURL":"https://api.synety.com/accounts/441452841172/calls/9429993/recordingurl?auth=f0833e607efe693b69e040ce12aac467&expiryDate=2014-03-22T16:25:20","CallRecordingHash":"f0833e607efe693b69e040ce12aac467","ConnectTime":"2013-09-16T12:20:15","DisconnectTime":"2013-09-16T12:20:34","LastUpdated":"2013-09-16T12:20:58Z","ExpiryTime":"2014-03-22T16:25:20.4147735+00:00","TransferTime":null,"ChargedAmount":0.01000,"ChargedTime":0,"CategoryID":null,"ContactID":null,"Category":null,"Contact":null,"CallStatus":null,"ForwardedCalls":null},{"id":8985051,"i_account":1985,"i_customer":654,"CallRecordingAvailable":true,"MP3RecordingAvailable":true,"Withheld":false,"Transfered":false,"CLD":"441534750520","CLI":"441452841172","Note":"","AccountID":"441452841172","call_id":"34e8901526185916939323k65950rmwp","SessionID":null,"Direction":"outbound","LastCallStatus":"","CallRecordingURL":"https://api.synety.com/accounts/441452841172/calls/8985051/recordingurl?auth=221c43cba757a5599d721baa6b56c9e6&expiryDate=2014-03-22T16:25:20","CallRecordingHash":"221c43cba757a5599d721baa6b56c9e6","ConnectTime":"2013-09-06T13:38:29","DisconnectTime":"2013-09-06T13:38:47","LastUpdated":"2013-09-06T13:39:30Z","ExpiryTime":"2014-03-22T16:25:20.4147735+00:00","TransferTime":null,"ChargedAmount":0.01000,"ChargedTime":0,"CategoryID":null,"ContactID":null,"Category":null,"Contact":null,"CallStatus":null,"ForwardedCalls":null}]
[/code]
Previously my code has searched and replaced the name part of the name value pairs to produce a value array that datatables understands. However the provider keeps changing the order of the fields in the feed and when I complain, tells me "JSON is an unordered set of name value pairs", to which I responded "It doesn't have to be!".
Anyway, any idea how I can cope with the random field positions?
This discussion has been closed.
Replies
This blog post has more information for 1.9-: http://datatables.net/blog/Extended_data_source_options_with_DataTables
And for 1.10+: http://next.datatables.net/manual/data#Objects
That way, no conversion is needed - just always use the raw JSON data source.
Allan