0
votes

I have one very simple html page containing 3 text fields and one save button. On click of the save button I just want to save the entered value as json data into "test.json" file. And I am using EXTJS 4. I have just started learning EXTJS4, so if anybody code examples that will be GREAT. :-) Thanks in advance...!

1

1 Answers

0
votes

you could make a string like this

{"data":[{"firstname":"Jeans","lastname":"Louis","job":"developper"}]}

and save it to a file

Or you could use the build in feature, this is from the ExtJs API

Modified version of Douglas Crockford"s json.js that doesn"t mess with the Object prototype http://www.json.org/js.html
Defined By
Methods

Ext.JSON
view source
decode( String json, [Boolean safe] ) : Object
Decodes (parses) a JSON string to an object. ...

Ext.JSON
view source
encode( Mixed o ) : String
Encodes an Object, Array or other value ...

Ext.JSON
view source
encodeDate( Date d ) : String
Encodes a Date. ...

eg

var elemt = Ext.JSON.encode('your Object') 

About the writing to a file, i suppose you mean on the server ? On the client that would be problematic..