includes/clientside/static/json.js
changeset 873 285f0c6d9c9a
parent 582 a38876c0793c
child 1227 bdac73ed481e
equal deleted inserted replaced
872:8b42e51bb6e6 873:285f0c6d9c9a
     9     
     9     
    10 */
    10 */
    11 
    11 
    12 function toJSONString(input)
    12 function toJSONString(input)
    13 {
    13 {
       
    14   if ( window.JSON )
       
    15   {
       
    16     return window.JSON.stringify(input);
       
    17   }
    14   var m = {
    18   var m = {
    15           '\b': '\\b',
    19           '\b': '\\b',
    16           '\t': '\\t',
    20           '\t': '\\t',
    17           '\n': '\\n',
    21           '\n': '\\n',
    18           '\f': '\\f',
    22           '\f': '\\f',
   140   }
   144   }
   141 }
   145 }
   142 
   146 
   143 function parseJSON(string, filter)
   147 function parseJSON(string, filter)
   144 {
   148 {
       
   149   if ( window.JSON )
       
   150   {
       
   151     return window.JSON.parse(string);
       
   152   }
       
   153   
   145   try {
   154   try {
   146     if (/^("(\\.|[^"\\\n\r])*?"|[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t])+?$/.
   155     if (/^("(\\.|[^"\\\n\r])*?"|[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t])+?$/.
   147             test(string))
   156             test(string))
   148     {
   157     {
   149   
   158