I'm working on a project developed for Android and using Titanium Studio 3.2.0 and Titanium SDK 3.2.0.GA.
I'm using Appcelerator Urban Airship module, I can connect with no problem, the main issue is that the payload I receive from Urban Airship looks like this:
{prop1={"key1":"val1","key2":"val2","key3":"val3"}}
Which is a string, not an object like you do in iOS.
The extra sent through curl like this:
curl -X POST -u "appkey:secret" \
-H "Content-Type: application/json" \
-H "Accept: application/vnd.urbanairship+json; version=3;" \
--data '{"audience": {"alias": "foo"},"notification": {"alert":"hello","android": {"extra": {"prop1": "{\"key1\":\"val1\",\"key2\":\"val2\",\"key3\":\"val3\"}"}}},"device_types": ["android"]}' \
https://go.urbanairship.com/api/push/
Is that a valid JSON object? I can't parse it with JSON.parse
because of the = symbol, I could replace it but if I were to send an extra that contained several objects I was wondering if there was a way to quickly parse this kind of object.
Just to be clear, this is what I'm sending:
{"audience": {"alias": "foo"},"notification": {"alert":"hello","android": {"extra": {"prop1": "{\"key1\":\"val1\",\"key2\":\"val2\",\"key3\":\"val3\"}"}}},"device_types": ["android"]}
The bold is the payload I'm sending through Urban Airship. What I'm receiving on my app is the following:
{prop1={"key1":"val1","key2":"val2","key3":"val3"}}
If I were to send something like:
{"audience": {"alias": "foo"},"notification": {"alert":"hello","android": {"extra": {"prop1": "{\"key1\":\"val1\",\"key2\":\"val2\",\"key3\":\"val3\"}","prop2": "{\"key4\":\"val4\",\"key5\":\"val5\",\"key6\":\"val6\"}",...,"propN": "{\"keyX\":\"valX\",\"keyY\":\"valY\",\"keyZ\":\"valZ\"}"}}},"device_types": ["android"]}
I might receive a string that looks something like:
{prop1={"key1":"val1","key2":"val2","key3":"val3"},prop2={"{"key4":"val4","key5":"val5","key6":"val6"}",...,propN={"{"keyX":"valX","keyY":"valY","keyZ":"valZ"}"}
I want to know if there is a quick way to turn a string that looks like this into a JSON object. I know the string isn't a valid JSON object but if Urban Airship is sending something that looks like that then there should be a way to deal with an object that looks like this.