JSON, URL-encode, and UTF-8

Peter W A Wood peterwawood at gmail.com
Fri Aug 21 09:20:25 CEST 2015


> On 21 Aug 2015, at 10:59, Peter W A Wood <peterwawood at gmail.com> wrote:
> 
> Jacque
> 
>> On 21 Aug 2015, at 10:13, J. Landman Gay <jacque at hyperactivesw.com <mailto:jacque at hyperactivesw.com>> wrote:
>> 
>> Here's a test. This posts just fine in LC 6.x but fails in 7.0.6 and 7.1rc1.
>> 
>> Make a field with this in it:
>> 
>>   [{"Meals":"Yes","Purpose":"Business"}]
>> 
>> Now put this into a button or card script:
>> 
>> constant kServerURL = "https://www.domain.com/results.php <https://www.domain.com/results.php>"  --### use a valid URL here
>> 
>> 
>> command sendToServer
>>  if the version < 7 then
>>    put fld 1 into tData
>>    put "json=" before tData
>>  else
>>    put textEncode(fld 1,"UTF8") into tData
>>    put textEncode("json=",UTF8) before tData
>>  end if
>>  post tData to kServerURL
>>  put it into tResponse
>>  put the result into tErr
>>  breakpoint -- so you can see it
>> end sendToServer
>> 
>> If someone can test this against a simple echo PHP maybe it will tell us something. The real server returns empty in LC 7 and "OK" in LC 6.
> 
> This works fine in LiveCode 7.0.3. I’ll download 7.1RC1 and see if it works there too.
> 
> Peter
> 

It also works on LiveCode 7.1 RC1 … which took me hours to download :-(

Regards

Peter



More information about the use-livecode mailing list