JSON

Thomas McGrath III mcgrath3 at mac.com
Tue Jun 4 21:33:25 EDT 2013


Andrew, That did it. I had the headers wrong.

  set the httpHeaders to "Content-Type: application/json"

worked and not set the httpHeaders to "text/json" did not.

It actually worked. THanks to everyone who helped me out.

Tom

-- Tom McGrath III
http://lazyriver.on-rev.com
mcgrath3 at mac.com

On Jun 4, 2013, at 7:40 PM, Andrew Kluthe <andrew at ctech.me> wrote:

> I dont know about the libraries he is using, but if it is based at all on
> the late mark smiths's the numbers in his array would translate to integers
> in terms of the json it spits out. I actually had to modify the output of
> the mark smith library to place 0's before decimal points to avoid bad
> request errors.
> 
> {
>  "data": {
>    "appuser_details": {
>      "name": "Tom_iPad",
>      "email": "iPad at gmail.com",
>      "device_type": "2",
>      "dentist_id": "73",
>      "device_token":
> "98be5c7a3cc9e400ae6a90977ac6d64f498bb01cbe83c3c3d1bb4856de59ba1c"
>    }
>  }
> }
> 
> Also doing something like
> 
> set the httpHeaders to "Content-Type: application/json"
> 
> could help if you aren't doing this already.
> 
> Hmm, I wonder why your back end developer would be looking to use strings
> in the place of integers. I
> 
> 
> On Tue, Jun 4, 2013 at 6:13 PM, Monte Goulding
> <monte at sweattechnologies.com>wrote:
> 
>> 
>> On 05/06/2013, at 8:57 AM, J. Landman Gay wrote:
>> 
>>> I got the same error at first. The web server can't understand what
>> you're sending.
>>> 
>>> You just need to create a regular LiveCode array (none of that
>> punctuation stuff,) pass it through Igor's library, and then send a POST
>> with whatever you get back. I'm not sure about the headers, I don't think I
>> had to change those but it might depend on the server.
>>> 
>>> Something like this off the top of my head:
>>> 
>>> put "Tom_iPad" into tArray["data"]["appuser_details"]["name"]
>>> put "iPad at gmail.com" into tArray["data"]["appuser_details"]["email"]
>>> ...etc
>>> put jsonFromArray(tArray) into tJSON
>>> post tJSON to "http://xxx.xxx"
>>> 
>>> You might have to twiddle that a bit.
>> 
>> Ah... how is that library working out if something is a number or a
>> string? If it's doing it's just using "is a number" then given you have
>> numbers that you need to send as strings you're going to have a problem.
>> You might need to look at the api and find out if it has a way to force
>> elements to be a string. Alternatively... seeing as it's really not a big
>> document and you don't need to do JSONToArray you could just put a template
>> in a custom property and use merge...
>> 
>> Cheers
>> 
>> --
>> M E R Goulding
>> Software development services
>> Bespoke application development for vertical markets
>> 
>> mergExt - There's an external for that!
>> 
>> _______________________________________________
>> use-livecode mailing list
>> use-livecode at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>> 
> 
> 
> 
> -- 
> Regards,
> 
> Andrew Kluthe
> andrew at ctech.me
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode




More information about the use-livecode mailing list