Results 1 to 4 of 4

Thread: Invalid JSON String Ext.JSON.decode

  1. #1
    Sencha User
    Join Date
    Feb 2015
    Posts
    2

    Default Invalid JSON String Ext.JSON.decode

    Ext.JSON.decode (Ext JS 6.5.3.57) successfully decodes (parses) a JSON string '{name:"John", age:30, city:"New York",}' to an object, but Ext.JSON.decode (Ext JS 6.6.0 and 6.7.0) returns an exception "You're trying to decode an invalid JSON String".
    I do not believe this is a bug, rather it has changed functionality. Is there a way to work Ext.JSON.decode
    (Ext JS 6.6.0 and 6.7.0) as in 6.5.3?

    Regards

  2. #2
    Sencha Premium User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,250
    Answers
    758

    Default

    Code:
     '{name:"John", age:30, city:"New York",}
    Is not valid JSON. However, in 6.6, they changed the JSON parsing method to the native browser method, which is stricter in what it will parse. You're better off just fixing your JSON.
    Twitter - @evantrimboli
    Former Sencha framework engineer, available for consulting.
    As of 2017-09-22 I am not employed by Sencha, all subsequent posts are my own and do not represent Sencha in any way.

  3. #3
    Sencha User
    Join Date
    Feb 2015
    Posts
    2

    Default

    Yes, this is not a valid JSON string, but it was convenient to dynamically add components if, for example, the string is stored in a text field in a database such as:

    jsonText = '{ xtype: "xyz",
    items: [{//inner items config ...}, {}]
    }'

    container.add(
    Ext.JSON.decode(jsonText)
    )

    which now I do not see an easy way of doing.

  4. #4
    Ext JS Premium Member dtex-lab's Avatar
    Join Date
    Sep 2009
    Location
    Italy
    Posts
    411

    Default

    You can set Ext.USE_NATIVE_JSON to false to return back to ExtJS 6.5.3 functionality.
    we make IT work for you

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •