O'Reilly logo

Ext JS 4 Web Application Development Cookbook by Stuart Ashworth, Andrew Duncan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Encoding and decoding JSON data

JavaScript Object Notation (or JSON) is a lightweight data interchange format that's human readable and very useful for representing simple data structures and data objects.

As JSON is language independent, it's ideal for use with frameworks such as Ext JS.

Ext JS has an excellent range of functions that work with JSON. However, let's start at the beginning with encoding and decoding data in JSON format.

Note

A useful tool when working with JSON is the online JSON validator JSON Lint, which validates and formats JSON. This is available at www.jsonlint.com.

How to do it...

  1. Start by creating a JavaScript object. We're going to encode this object as JSON:
    var objToEncode = { foo: "bar", id: 1, today: new Date(), isJson: true, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required