Search code examples
titaniumxmlhttprequestappcelerator-mobile

Appcelerator Titanium XHR POST params as multi-level array


Ti.SDK 1.6.2
iOS 4.3

I have a web application that receives post data as multi-level arrays.

Array
(
    [User] => Array
        (
            [name] => Josey Morton
            [username] => jmorton
            [password] => ########
        )

    [Product] => Array
        (
            [name] => Pro Drupal Development
            [type] => Book
            [price] => 49.99
        )

)

My serverside app then takes the contents of "User" and "Product" and parses them differently, storing them in their respective databases.

My question:

How can I pass this format as the HTTPClient send params so no adjustment is needed on the server side?


Solution

  • I ended up passing it as a JSON serialized string and decoded the JSON server side. This allowed for the hierarchical post array I required.