I have a data structure like socket
var s = { "a": "foo", "b": 5, "c": {"d": "a long string"}, "e": { "f": { "g": { "h": [1, 0, -2.1, 1.43] } }, "i": { "j": { "k": [-3.2, 3.003, 0, 0] } } } };
I want to save the keys "a", "b", "c" and "e" of the variable s
in the database table so that I can restore them again. I am posting s
via jQuery AJAX POST. Values will be inserted and saved as plain text (except for "b", which is always a number).
ajax: { url: uri, type: "POST", data: s, dataType: "json", success: function(data, status) { .. } }
Here is the problem I am facing. In Firebug, I see my message options ... they are really messed up. It looks like the data was serialized at the level of each element (like deep serialization), while I was hoping for something like
e={"f":{"g":{"h":[1,0,-2.1,1.43]}},"i":{"j":{"k":[-3.2,3.003,0,0]}}}
Update : instead, I get the following (I have an unescaped line below, so it is more readable)
a=foo&b=5&c[d]=a long string&e[f][g][h][]=1&e[f][g][h][]=0&e[f][g][h][]=-2.1&e[f][g][h][]=1.43
Maybe I'm doing it wrong, so feel free to guide me on a better path.