Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

POST a JSON array with Titanium Mobile

I must be trying too hard or there seems to be an error with the way JSON is being POSTed.

The following structure works for example with jQuery:

    'object': { 'child1':'value', 'child2':'value' }

But it's not nesting correctly with Titanium Mobile.

My web app keeps seing something like object = "{\'child1\' ...

Am I doing something wrong or is this is a platform bug?

Thanks for any help.

— asked September 10th 2010 by Alexandre Loureiro Solleiro
  • http
  • json
  • mobile
  • network
  • post
  • xhr

2 Answers

  • Are you sure you can send a nested json over http?

    You may try this:

        object: { child1:'value', child2:'value' }

    or if it doesn't work, you can try to stringify the json, send it as a simple string variable and parse it serverside.

    — answered September 11th 2010 by Dan Tamas
    1 Comment
    • Thank you for your response.

      Yes you can send JSON over HTTP, but it turns out I needed to make sure it was JSON I was sending!

      This now works for me (it also works if keys are of the 'child1' sort):

      var postData = {
          object: { child1:'value', child2:'value' }

      — commented September 11th 2010 by Alexandre Loureiro Solleiro
  • function setTask(idUser, idService, Reason){
            xhrPost.open('POST', myPost);

    works so in my case

    — answered September 11th 2010 by Andrea S
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.