Re: mergeJSON on server problem

2020-11-05 Thread David Bovill via use-livecode
Let me dig into this in more detail with some tests - other data encoding is 
causing problems. Note I only find this on the unix server not with the local 
MacOS version of the same code and data.

I’m going to refer to this stack overflow answer regarding encoding:

https://stackoverflow.com/questions/583562/json-character-encoding-is-utf-8-well-supported-by-browsers-or-should-i-use-nu
On 2 Nov 2020, 09:28 +, Monte Goulding via use-livecode 
, wrote:
>
>
> > On 1 Nov 2020, at 6:21 am, David Bovill via use-livecode 
> >  wrote:
> >
> > Thanks Mark - I may give fastjson a go.
> >
> > I tracked down the problem to the "\u00a0” unicode character in the json I 
> > fetched, which was causing mergeJSON to fail. This hack fixed the issue in 
> > a temporary way.
> > replace "\u00a0” with empty in episodeJson -- hack to remove "¬"
> >
> > Any thoughts on safe encoding of data I fetch fro jsonrpc calls so that it 
> > plays nicely with Livecode?
>
> Hi David
>
> The following seems to work without error:
> put format("[ \"\\u00a0\" ]") into tJSON; get JSONToArray(tJSON); put tJSON 
> && it[1]
>
> Cheers
>
> Monte
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: mergeJSON on server problem

2020-11-02 Thread Monte Goulding via use-livecode


> On 1 Nov 2020, at 6:21 am, David Bovill via use-livecode 
>  wrote:
> 
> Thanks Mark - I may give fastjson a go.
> 
> I tracked down the problem to the "\u00a0” unicode character in the json I 
> fetched, which was causing mergeJSON to fail. This hack fixed the issue in a 
> temporary way.
>   replace "\u00a0” with empty in episodeJson -- hack to remove "¬"
> 
> Any thoughts on safe encoding of data I fetch fro jsonrpc calls so that it 
> plays nicely with Livecode?

Hi David

The following seems to work without error:
put format("[ \"\\u00a0\" ]") into tJSON; get JSONToArray(tJSON); put tJSON && 
it[1]

Cheers

Monte
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: mergeJSON on server problem

2020-10-31 Thread David Bovill via use-livecode
Thanks Mark - I may give fastjson a go.

I tracked down the problem to the "\u00a0” unicode character in the json I 
fetched, which was causing mergeJSON to fail. This hack fixed the issue in a 
temporary way.
replace "\u00a0” with empty in episodeJson -- hack to remove "¬"

Any thoughts on safe encoding of data I fetch fro jsonrpc calls so that it 
plays nicely with Livecode?
On 31 Oct 2020, 18:29 +, Mark Wieder via use-livecode 
, wrote:
> On 10/31/20 10:27 AM, David Bovill via use-livecode wrote:
> > I use mergeJSON to move back an forth between json and arrays for web 
> > services. It’s currently failing when I fetch json data from another source 
> > on the Ubuntu server, while the same code and data works on MacoS - 
> > presumably due to some encoding issues.
> >
> > It’s a large amount of data and I can’t debug where the issue is easily. 
> > Maybe I can use jsonImport/Export on the server? Not sure. Any thoughts?
>
> Is this any help? Hard to tell without knowing what's failing.
>
> https://quality.livecode.com/show_bug.cgi?id=19698
>
> --
> Mark Wieder
> ahsoftw...@gmail.com
>
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: mergeJSON on server problem

2020-10-31 Thread Mark Wieder via use-livecode

On 10/31/20 10:27 AM, David Bovill via use-livecode wrote:

I use mergeJSON to move back an forth between json and arrays for web services. 
It’s currently failing when I fetch json data from another source on the Ubuntu 
server, while the same code and data works on MacoS - presumably due to some 
encoding issues.

It’s a large amount of data and I can’t debug where the issue is easily. Maybe 
I can use jsonImport/Export on the server? Not sure. Any thoughts?


Is this any help? Hard to tell without knowing what's failing.

https://quality.livecode.com/show_bug.cgi?id=19698

--
 Mark Wieder
 ahsoftw...@gmail.com

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


mergeJSON on server problem

2020-10-31 Thread David Bovill via use-livecode
I use mergeJSON to move back an forth between json and arrays for web services. 
It’s currently failing when I fetch json data from another source on the Ubuntu 
server, while the same code and data works on MacoS - presumably due to some 
encoding issues.

It’s a large amount of data and I can’t debug where the issue is easily. Maybe 
I can use jsonImport/Export on the server? Not sure. Any thoughts?
On 31 Oct 2020, 02:29 +, Roger Guay via use-livecode 
, wrote:
> Lots of clever ideas here, Alex, but I think you’re missing the point of what 
> I ultimately want to do. I'm building a plotting program for which I want to 
> plot any equation including those that have multiple values of y for a given 
> x. An equation might branch at any point and might even have multiple 
> branches both of which are unknown before plotting.
>
> Of course, there’s always the possibility that I’m not fully comprehending 
> your suggestions??? What does NB stand for? Are you suggesting creating a new 
> polygon every time a branch is detected? That just might work?!
>
> Roger
>
>
> > On Oct 30, 2020, at 4:12 PM, Alex Tweedly via use-livecode 
> >  wrote:
> >
> >
> > On 30/10/2020 22:40, Roger Guay via use-livecode wrote:
> > > Let’s try this again after spellchecking:
> > >
> > >
> > > Yes, yours is a good example of a bifurcated line. But now imagine 
> > > producing this line programmatically with an equation that:
> > >
> > > Produces a constant y value of 149 as x progresses from 35 to 235 (no 
> > > problem)
> > > Then produces 2 different but simultaneous values of y as x progresses 
> > > from 235 to 335. This is the problem as you don’t want the end point of 
> > > the separated lines to connect. If you place an empty line in the points 
> > > after each iteration beyond x = 235 then you end up with the bifurcated 
> > > lines being points rather than a solid line.
> > >
> > > How do plotting programs handle this situation
> >
> >
> > Here are two different ways you could do it.
> >
> > 1. simple - assume there would (could) be two Y values for any x, and just 
> > calculate two series, and combine them for output.
> >
> > 2. harder - for each x value, keep track of the previous y value for each 
> > series, and if necessary, put in a 'skip' plus new value plus skip ...
> >
> > NB makes for a more complex polygon; each new x value after bifurcation 
> > results in 5 lines added to the points.
> >
> > on mouseup
> > local tSeries1, tSeries2, thepoints
> > if the shiftkey is down then
> >
> > -- the easy way - just allow for the possibility of two series of points 
> > all along
> > repeat with i = 35 to 335
> > -- calculate series 1
> > if i < 235 then
> > put i,249  after tSeries1
> > else
> > put i, 249+(i-235)  after tSeries1
> > end if
> > -- calculate series 2
> > if i < 235 then
> > -- do nothing - it's the same as series 1
> > else
> > put i, 249+2*(i-235)  after tSeries2
> > end if
> > end repeat
> >
> > put tSeries1  & tSeries2 into thePoints
> > set the points of grc "X" to thePoints
> > set the foregroundColor of grc "X" to "blue"
> > else
> > -- the harder way - multiple series ...
> > -- does each step for each series ... much more complex polygon, but ...
> > local t1, t2, tLast1, tLast2
> > repeat with i = 35 to 335
> > -- calculate values
> > if i < 235 then
> > put 249 into t1
> > put 249 into t2
> > else
> > put 249+(i-235) into t1
> > put 249+2*(i-235) into t2
> > end if
> > -- put in series 1
> > if tLast1 is not empty then
> > put i-1, tLast1  & i, t1  after thePoints
> > end if
> > -- possibly put in series 2
> > if tLast1 <> tLast2 OR t1 <> t2 then
> > put CR after thePoints -- blank skip over to series 2 value
> > put i-1, tLast2  & i, t2  after thePoints
> > put CR after thePoints -- blank skip back to series 1
> > end if
> > put t1 into tLast1
> > put t2 into tLast2
> > end repeat
> > set the points of grc "X" to thePoints
> > set the foregroundColor of grc "X" to "red"
> > end if
> >
> > end mouseup
> >
> >
> > ___
> > use-livecode mailing list
> > use-livecode@lists.runrev.com
> > Please visit this url to subscribe, unsubscribe and manage your 
> > subscription preferences:
> > http://lists.runrev.com/mailman/listinfo/use-livecode
>
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode