This topic contains 1 reply, has 2 voices, and was last updated by  Wade 2 months, 3 weeks ago.

An interesting json.parse error

  • I found a scenario where the json.parse method fails when encountering the “\f” escape sequence.
    The first example below (t1) parses successfully.
    The second example (t2) fails with this error:

    Error parsing JSON: invalid string sequence at position 236 see: 
    eats\n\rwith\r\n\fSubsequent a\ts
    -----------------^
    
    local t1 = '{"field" : "casey\r\neats\n\rwith\r\n\fSubsequent a\tspoon"}'
    local t2 = 
    [[
    [
       {
          "field1" : "value1",
          "field2" : "value2",
          "list1" : [
             {
                "field1" : "value1",
                "field2" : "value2",
                "field3" : "casey\r\neats\n\rwith\r\n\fSubsequent a\tspoon"
             },
             {
                "field1" : "value1",
                "field2" : "value2",
                "field3" : "casey\r\neats\n\rwith\r\n\fSubsequent a\tspoon"
             }
          ]
       }
    ]
    ]]
    
    local r1 = json.parse{data=t1}
    local r2 = json.parse{data=t2}
    

    Hi Casey,

    Sorry about that. We’ve recently done some work on upgrading our JSON parsing library and it looks like this issue will be fixed when we release 6.1.1. We don’t have an official release date yet, but I’ve made a note to send you an email when it’s released.

    Wade

You must be logged in to reply to this topic.