You were correct.
I discovered that javascript was expanding the json string into an object and when I packed the object back into another encoded string using $.toJSON(item) (an available plugin) it all worked as expected. I've been working long crazy hours, but I could swear that before when I was loading each each row retrieved from a MySQL call into an array, then running json_encode on the array, that it was working. Now, I can see that each entry (prior to storing in an array will be rendered correctly with json_encode, but the entire array does not. I lose the values for any field that contains binary data. Sigh, you fix one problem and a hundred more are waiting. On Oct 28, 9:09 am, joel boonstra <[EMAIL PROTECTED]> wrote: > > I have an object created using json_encode and via the console.log > > entry as suggested, I can see that it is correct. I have a backend > > program that I'm wanting to pass this object to, so that it can do a > > json_decode and then process that data. When I try to pass the > > object to it, using: > > $.post(prog,{data:data},function(){},"json"); the result is that > > the backend program receives a $_POST['data'] that looks like: > > [object Object] instead of the json_encoded string. > > > I'm pulling my hair out on this.. > > I think what's happening is that you're trying to send a full-fledged > object along as part of a POST payload, and JavaScript needs to > convert it to a string so that it knows how to send it via HTTP. > Converting an object to a string doesn't necessarily give you a JSON > representation of the object; instead, you get as best a string > representation as Firefox can muster--'[object Object]'. That fourth > parameter to $.post ('json', the type parameter) indicates how to > treat the server *response*, not how to send data to the server. > > What does your 'data' object look like? Is it simply key => value > pairs? You might be able to get away with this: > > $.post(prog, data, function () { }, 'json'); > > and PHP will receive one entry in $_POST for each key in your data > object. If you do that, the object will be sent as a normal key=value > POST payload, rather than as a JSON object bundled in one variable. > Since HTTP supports transporting data this way, it makes sense (to me) > to take advantage of that. > > If that doesn't work for you, you'll need to serialize your actual > object into its JSON string representation before sending it along to > the server; I'm not sure the best method for reliably doing that. I > don't *think* jQuery has a method for that, but I wouldn't swear to > it. You're looking for something like: > > http://www.nabble.com/How-to-serialize-an-Object-to-JSON-String-witho... > > with some more discussion here: > > http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&... > > But like I say, I'm a fan of using HTTP's built-in mechanism (query > strings) for transporting structured data *to* a server, and letting > the backend server and language deal with figuring it out. > > HTH