libJson not working. SDK config issue?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
libJson not working. SDK config issue?
I'm wondering if anyone might be able to help. I'm in the Create It with Livecode course and am having an issue I think related to my Android SDK configuration. When I try to use jsonToArray() on the Android Sim or device, the array return has no data (as far as I can tell). Json going in is correct. I am able to get jsonToArray() to work on LC community & Indy as well as IOS Sim and devices. Just not Android.
I put together a simple stack that gets IP location, shows json data, array data and city, region and Lat, Long. Nothing fancy. On my system when using Android json data is valid but jsonToArray() is blank. This stack is based on the very start of one of the Apps in the CIwLC class.
Any thoughts before I go line by line in jsonToArray to see what's not working? NOTE: I put the libJson stack script in the stack script of test stack with no difference in results. You will see attached stack does not use libJson as a library.
Thanks in advance,
Bob
I put together a simple stack that gets IP location, shows json data, array data and city, region and Lat, Long. Nothing fancy. On my system when using Android json data is valid but jsonToArray() is blank. This stack is based on the very start of one of the Apps in the CIwLC class.
Any thoughts before I go line by line in jsonToArray to see what's not working? NOTE: I put the libJson stack script in the stack script of test stack with no difference in results. You will see attached stack does not use libJson as a library.
Thanks in advance,
Bob
- Attachments
-
- jsonTest.livecode.zip
- (6.45 KiB) Downloaded 226 times
Re: libJson not working. SDK config issue?
Hi Bob,
I do't know the reason yet but it's line 123
Comment it out
And it works.
Simon
Edit; after working on it a while I think you can call this a bug, will you bug report it?
I do't know the reason yet but it's line 123
Comment it out
Code: Select all
repeat with n = 1 to sNumTokens - 1
-- if (sJson[n] is not in "{}[],:") and (sJson[n + 1] is not in "{}[],:") then return "libJson-error: json malformed"
end repeat
Simon
Edit; after working on it a while I think you can call this a bug, will you bug report it?
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
Re: libJson not working. SDK config issue?
I can submit the bug but do you think it would be helpful to further isolate the issue down to it's root cause and take libJson out of the mix. It appears as though it's an issue with strings and some "special" characters on Android. And as this effects libJson I'm tempted to leave that in the mix as it's a very important library for mobile Android Apps and see how much convincing needs to be done that's it's not libJson.
Here's what I did. Commented out the original line 123. Broke it up into pieces and added a couple of answer dialogs (quick and dirty just to see what's up and PS, don't run this on anything but android sim or device as you'll get a ton of answer dialogs to "OK"
when n=1 data is...
tToken1 = { (correct)
tToken2 = as (correct)
tFlag1 = true (wrong)
tFlag2 = true (correct)
And we return json malformed as a result.
I could create another stack that focuses just on this if that would be better for the LC team.
BTW, great find on the exact line.
Bob
Here's what I did. Commented out the original line 123. Broke it up into pieces and added a couple of answer dialogs (quick and dirty just to see what's up and PS, don't run this on anything but android sim or device as you'll get a ton of answer dialogs to "OK"

Code: Select all
repeat with n = 1 to sNumTokens - 1
--if (sJson[n] is not in "{}[]:,") and (sJson[n + 1] is not in "{}[],:") then return "libJson-error: json malformed"
put sJson[n} into tToken1
put sJson[n+1] into tToken2
answer tToken1 & "|" & tToken2
put "{}[],:" into searchString
if tToken1 is not in searchString then put true into tFlag1 else put false into tFlag1
if tToken2 is not in searchString then put true into tFlag2 else put false into tFlag2
answer tFlag1 & "|" & tFlag2
if tFlag1 and tFlag2 then return "libJson-error: json malformed"
end repeat
tToken1 = { (correct)
tToken2 = as (correct)
tFlag1 = true (wrong)
tFlag2 = true (correct)
And we return json malformed as a result.
I could create another stack that focuses just on this if that would be better for the LC team.
BTW, great find on the exact line.
Bob
Re: libJson not working. SDK config issue?
Hi Bob,
I tried many variations like yours but could not fix it.
Reducing the code to
Works fine on Android, so it's not "is not in".
I think it's ok to just post the code "as is" because it's dependent on many things and jsonToArray is a well known function.
Just tested in 6.7.2 and it's working. So even more reason to post as is.
Simon
I tried many variations like yours but could not fix it.
Reducing the code to
Code: Select all
on mouseUp
if "a" is not in "{}[]:," then
answer "This is working"
else
answer "BROKEN"
end if
end mouseUp
I think it's ok to just post the code "as is" because it's dependent on many things and jsonToArray is a well known function.
Just tested in 6.7.2 and it's working. So even more reason to post as is.
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
Re: libJson not working. SDK config issue?
Hi Bob,
Once you post the bug please post it's number here so I can follow.
Thanks,
Simon
Once you post the bug please post it's number here so I can follow.
Thanks,
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
Re: libJson not working. SDK config issue?
Bug filed.
http://quality.runrev.com/show_bug.cgi?id=15151
For now I'm going to put a conditional around it checking if we're on Android and just skip the error checking. Not perfect but at least App works now on Android.
Thanks again Simon for the pinpoint accuracy.
Bob
http://quality.runrev.com/show_bug.cgi?id=15151
For now I'm going to put a conditional around it checking if we're on Android and just skip the error checking. Not perfect but at least App works now on Android.
Thanks again Simon for the pinpoint accuracy.
Bob