javascript - Parsing invalid JSON string to JSON2 in java script -
i have invalid json string below wanted convert json. want rid of eval(). json.parse() throwing exception. there anyother way this?
"{user:'c3dc5ff987acb5c8cb7adf9d774775fa', recover:[{client:'call', call:{cti_telephone_called:'sip:217812@ukavayatest.fnfis.com;user=phone', cti_caller_telephone:'0031205849948', cti_time_in_queue:'created:10:59:48 03/08/15;queued:11:00:42 03/08/15;answered:11:00:46 03/08/15', customer_nbr:'817', sortcodeacctno:'no_value', idvs:'3', skill:'sby sav se e blocked acct d', cdn_name:'sby sav se e blocked acct d', contact_id:'ukbiataaep-2015141090031-5', tp_call_type:'no_value', tp_call_status:'no_value'}, contactid:'ukbiataaep-2015086103648-14'},{end:'end'}]}"
well rules invalid json violating missing quotes around key names (like "name":
) , use of single quotes around string literals (like 'call'
). fix these need walk through string inserting quotes or replacing single quotes go (while keeping track of if inside string literal). generic solution complicated , yield little benefit on calling eval()
.
Comments
Post a Comment