In controller, I prepare a json object :--
import simplejson
D = {'a':1.23, 'b':'xyz'}
jsonD = simplejson.dumps(D, as_decimal=True)
This json object is sent to the browser.
An HTML input element is populated with this json object.
In the input box within the browser, it looks like this --->
[{"a":"1.23", "b":"abc"}]
(pl. note the [] brackets.
I was expecting something like this --->
{"a":"1.23", "b":"abc"}
(if the code is run in python shell, [ ] are not there).
So in javascript code, I need to parse it like this:
var txds = JSON.parse($('#json_input').val());
alert(txds[0]['acid']);
instead of this:
alert(txds['acid']);
How do I avoid the [ ]? (if possible)
Thanks,
Vineet