I have an API that returns me a string that contains an array of arrays. The arrays contains strings, like here:
"[['cat','mouse'],['duck','fish'],['lion','zebra']]"
and I want to convert it into a JSON object.
I've tried JSON.parse, but it's giving me an error
Blockquote [['+00:00 (Etc/GMT)','+00:00 (Etc/GMT)'],['+03:00 (Europe/Kaliningrad)','+03:0 ^ SyntaxError: Unexpected token '
The string that im trying to turn into an object is this one:
"[['+00:00 (Etc/GMT)','+00:00 (Etc/GMT)'],['+03:00 (Europe/Kaliningrad)','+03:00 (Europe/Kaliningrad)'],['-01:00 (Etc/GMT+1)','-01:00 (Etc/GMT+1)'],['AKST (America/Anchorage)','AKST (America/Anchorage)'],['ART (America/Argentina/Buenos_Aires)','ART (America/Argentina/Buenos_Aires)'],['AST (America/Puerto_Rico)','AST (America/Puerto_Rico)'],['AST (Asia/Baghdad)','AST (Asia/Baghdad)'],['AST (Atlantic/Bermuda)','AST (Atlantic/Bermuda)'],['BRT (America/Sao_Paulo)','BRT (America/Sao_Paulo)'],['CET (CET)','CET (CET)'],['CET (Europe/Amsterdam)','CET (Europe/Amsterdam)'],['CET (Europe/Brussels)','CET (Europe/Brussels)'],['CET (Europe/Budapest)','CET (Europe/Budapest)'],['CET (Europe/Madrid)','CET (Europe/Madrid)'],['CET (Europe/Oslo)','CET (Europe/Oslo)'],['CET (Europe/Paris)','CET (Europe/Paris)'],['CET (Europe/Prague)','CET (Europe/Prague)'],['CET (Europe/Vienna)','CET (Europe/Vienna)'],['CET (Europe/Warsaw)','CET (Europe/Warsaw)'],['CET (Europe/Zurich)','CET (Europe/Zurich)'],['CLST (America/Santiago)','CLST (America/Santiago)'],['COT (America/Bogota)','COT (America/Bogota)'],['CST (America/Chicago)','CST (America/Chicago)'],['CST (America/Costa_Rica)','CST (America/Costa_Rica)'],['CST (America/Mexico_City)','CST (America/Mexico_City)'],['CST (Asia/Shanghai)','CST (Asia/Shanghai)'],['CST (Asia/Taipei)','CST (Asia/Taipei)'],['CST (Australia/Adelaide)','CST (Australia/Adelaide)'],['EAT (Africa/Nairobi)','EAT (Africa/Nairobi)'],['EET (EET)','EET (EET)'],['EET (Europe/Istanbul)','EET (Europe/Istanbul)'],['EET (Europe/Kiev)','EET (Europe/Kiev)'],['EST (America/Indiana/Indianapolis)','EST (America/Indiana/Indianapolis)'],['EST (America/New_York)','EST (America/New_York)'],['EST (Australia/Brisbane)','EST (Australia/Brisbane)'],['EST (Australia/Melbourne)','EST (Australia/Melbourne)'],['EST (Australia/Sydney)','EST (Australia/Sydney)'],['GMT (Europe/Dublin)','GMT (Europe/Dublin)'],['GMT (Europe/London)','GMT (Europe/London)'],['GST (Asia/Dubai)','GST (Asia/Dubai)'],['HKT (Asia/Hong_Kong)','HKT (Asia/Hong_Kong)'],['HST (Pacific/Honolulu)','HST (Pacific/Honolulu)'],['ICT (Asia/Bangkok)','ICT (Asia/Bangkok)'],['IST (Asia/Jerusalem)','IST (Asia/Jerusalem)'],['IST (Asia/Kolkata)','IST (Asia/Kolkata)'],['JST (Asia/Tokyo)','JST (Asia/Tokyo)'],['KST (Asia/Seoul)','KST (Asia/Seoul)'],['MSK (Europe/Moscow)','MSK (Europe/Moscow)'],['MST (America/Denver)','MST (America/Denver)'],['MST (America/Phoenix)','MST (America/Phoenix)'],['MST (MST)','MST (MST)'],['MYT (Asia/Kuala_Lumpur)','MYT (Asia/Kuala_Lumpur)'],['NZDT (Pacific/Auckland)','NZDT (Pacific/Auckland)'],['PET (America/Lima)','PET (America/Lima)'],['PHT (Asia/Manila)','PHT (Asia/Manila)'],['PST (America/Los_Angeles)','PST (America/Los_Angeles)'],['PYST (America/Asuncion)','PYST (America/Asuncion)'],['SAST (Africa/Johannesburg)','SAST (Africa/Johannesburg)'],['SGT (Asia/Singapore)','SGT (Asia/Singapore)'],['TJT (Asia/Dushanbe)','TJT (Asia/Dushanbe)'],['UTC (UTC)','UTC (UTC)'],['VET (America/Caracas)','VET (America/Caracas)'],['WET (Europe/Lisbon)','WET (Europe/Lisbon)'],['WST (Australia/Perth)','WST (Australia/Perth)']]"
This is not valid JSON. You have to replace the '
characters with "
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With