#1 2012-03-10 09:56:08

esmondb
Member
From: London
Registered: 2010-07-20
Posts: 299

json parsing error

My browser if giving an 'invalid number' parsing error. It's being caused by a rawUTF8 field containing a single minus sign. I guess this is being treated as an integer so the quotes are missing. Can this be changed?

Offline

#2 2012-03-10 21:21:00

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,660
Website

Re: json parsing error

It is not easy to understand what is wrong here.

Could you post some code here in order to reproduce the problem?

RawUTF8 fields are always transmitted as JSON strings (with quotes).

So you are perhaps mixing types, in an unexpected way.

Offline

#3 2012-03-12 08:11:15

esmondb
Member
From: London
Registered: 2010-07-20
Posts: 299

Re: json parsing error

I might have got my code in a tangle.

As soon as I've time I'll put together an example.

Thanks

Offline

#4 2012-03-13 12:18:49

esmondb
Member
From: London
Registered: 2010-07-20
Posts: 299

Re: json parsing error

Looking at it again the function

function IsJSONString(P: PUTF8Char): boolean;

in SynCommons.pas is returning false if '-' or '+' is passed.
can plus or minus on it's own be regarded as a string?

Offline

#5 2012-03-13 12:24:15

esmondb
Member
From: London
Registered: 2010-07-20
Posts: 299

Re: json parsing error

BTW my code which caused the problem was:

Table := TSQLTableDB.Create(db,RecordClassesToClasses([TSQLRec, TSQLFTSRec]),SQLQuery,true);
aParams.Resp := Table.GetJSONValues(true);

Offline

#6 2012-03-13 13:47:33

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,660
Website

Re: json parsing error

You were perfectly right.

There was several issues in the string recognition pattern.
The IsJSONString() implementation and use was incorrect in some cases.

It should be fixed by now (and corresponding regression tests have been added).
See http://synopse.info/fossil/info/7444f84ec1

Thanks for the feedback.

Offline

Board footer

Powered by FluxBB