Getting JSON from Google Sheets with unicode chars

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

kaveh1000
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 539
Joined: Sun Dec 18, 2011 7:23 pm
Contact:

Re: Getting JSON from Google Sheets with unicode chars

Post by kaveh1000 » Mon Sep 30, 2019 9:01 pm

Kaveh

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4174
Joined: Sun Jan 07, 2007 9:12 pm

Re: Getting JSON from Google Sheets with unicode chars

Post by bn » Mon Sep 30, 2019 9:05 pm

kaveh1000 wrote:
Mon Sep 30, 2019 9:01 pm
Least I can do for you Bernd!!

https://docs.google.com/spreadsheets/d/ ... sp=sharing
Thanks Kaveh,

but this one also has only one column. Could you add a couple of columns?

Thanks
Bernd

kaveh1000
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 539
Joined: Sun Dec 18, 2011 7:23 pm
Contact:

Re: Getting JSON from Google Sheets with unicode chars

Post by kaveh1000 » Mon Sep 30, 2019 9:07 pm

Kaveh

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4174
Joined: Sun Jan 07, 2007 9:12 pm

Re: Getting JSON from Google Sheets with unicode chars

Post by bn » Mon Sep 30, 2019 9:18 pm

Hi Kaveh,

https://docs.google.com/spreadsheets/d/ ... sp=sharing

when I open the url in a browser I see 4 columns but only one is retrieved via your retrieval routine. And that one column is the same as before. Could you test this in your copy of "putJasonIntoTable.livecode"?

Column 2 and 4 have a lot of backslashes and curly brackets. Probably not the best test cases for Jason.

Kind regards
Bernd

kaveh1000
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 539
Joined: Sun Dec 18, 2011 7:23 pm
Contact:

Re: Getting JSON from Google Sheets with unicode chars

Post by kaveh1000 » Mon Sep 30, 2019 9:30 pm

did you put "four_rows" into the sheet name? I did and I think the columns are all coming in when I step through. However something seems to crash it out in the repeat look with numToCodepoint.

I bet it is one of the colons.

I have set up another sheet now, sheet4:

https://docs.google.com/spreadsheets/d/ ... 1713871980

you can edit this one, so do whatever...

I get repeating columns of numbers and then I think the fourth column..
Kaveh

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4174
Joined: Sun Jan 07, 2007 9:12 pm

Re: Getting JSON from Google Sheets with unicode chars

Post by bn » Tue Oct 01, 2019 12:15 am

Hi Kaveh,

I found the problem. The first one was a bug I did not catch with only one column. I overwrote rows with row numbers instead of only applying them to the first item only.

The second problem was in "four_rows" where you had a "\u" as a literal and it broke my assumption that "\u" is always the begin of a unicode hex.
Solution: I replaced "\\u" with "backslashU" in tData and restore after resolving unicode hex stuff.

I added an option menu where you can choose the four sheets I see easily and they all work now. It is good that you put up the torture tests and I am glad that they work now.

Kind regards
Bernd
Attachments
putJasonIntoTable_2.livecode.zip
now with even less errors
(2.46 KiB) Downloaded 248 times

kaveh1000
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 539
Joined: Sun Dec 18, 2011 7:23 pm
Contact:

Re: Getting JSON from Google Sheets with unicode chars

Post by kaveh1000 » Tue Oct 01, 2019 12:19 pm

Bernd, this is great. Thank you!
Kaveh

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4174
Joined: Sun Jan 07, 2007 9:12 pm

Re: Getting JSON from Google Sheets with unicode chars

Post by bn » Tue Oct 01, 2019 12:47 pm

Kaveh,

glad it helps. Is this helpful for your project?
This does not solve the problem of a cell containg more than one line. But I don't know of a way in livecode to put multiple lines into one cell of a table.

I had a look at the code again and there is one remnant line of an earlier attempt in handler "resolveArrayIntoTable"
put pDataArray["table"]["rows"][aRow]["c"] into tColumnNumber
which has no function in the current version. You could delete that line.

KInd regards
Bernd

kaveh1000
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 539
Joined: Sun Dec 18, 2011 7:23 pm
Contact:

Re: Getting JSON from Google Sheets with unicode chars

Post by kaveh1000 » Tue Oct 01, 2019 2:12 pm

Hi Bernd

Yes, this is very helpful, as I have so many strange characters. So glad I had the "\u" in the set and so glad you spent time solving it!! I still have not had time to go thro in detail but it will be very useful for me to do that.

I don't actually need the data in a table in LiveCode. I think I can work out a way of dealing with returns in a cell.

thanks again.
Kaveh

Post Reply