简体   繁体   中英

Parse String Without using JSON.parse

Good day. I have an array that needs to be parsed in a JSON format. However, the browser object does not support JSON calls...unfortunately. Is there a way to brute force the script into a JSON parse without explicitly calling it?

Essentially, I am calling data from a SQL tbl and need to retrieve the data in order to make a table. I need the array parsed in order to make a html table into rows and columns.

Any help is most appreciated.

Current Array No Parsing

"[["0","Accumulation is at 100% Full","78"],["0","Accumulation is at 50% Full","77"],["1","Accumulation Time Purge Warning","79"]]"

Desired Array with Parsing

  0:Array(3)
    0:"0"
    1:"Accumulation is at 100% Full"
    2:"78"
    length:3
    __proto__:Array(0)
  1:Array(3)
    0:"0"
    1:"Accumulation is at 50% Full"
    2:"77"
    length:3
    __proto__:Array(0)
  2:Array(3)
    0:"1"
    1:"Accumulation Time Purge Warning"
    2:"79"
    length:3
    __proto__:Array(0)

Use $.parseJSON() . If the browser doesn't support JSON.parse() , it provides a polyfill.

Make sure you're using jQuery 1.11 or higher. Earlier versions of jQuery used code equivalent to eval() for this polyfill, so it was dangerous. jQuery 1.11 has better validation of the input.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM