Disconcerning diffrences between serializejson and serialize

Hi All

I came across a strage issue today, when storing data in a database I use
serializejson when I retrieve it I use deserializejson
for some reason I am getting “invalid construct” when trying to
deserializejson if I change this to use serialize instead of serializejson
it works fine (with deserializejson I dod not try plain deserialize), if I
check the data directly in the database the only diffrence is that the
serializejson method uses double quotes and the serialize uses single
quotes, so I tried a deserializeJson(replace(sVars.cVal, "", “”, “ALL”))
and this works on original data, I found this most baffling

is this bug in deserializeJson?

Regards

GX

Thanks for the help all, I found the bug… I was doing a jsStringFormat
after reading the data from the database, that was the cause

Regards

GXOn Monday, March 30, 2015 at 9:11:54 AM UTC+3, mail...@gmail.com wrote:

Hi All

I came across a strage issue today, when storing data in a database I use
serializejson when I retrieve it I use deserializejson
for some reason I am getting “invalid construct” when trying to
deserializejson if I change this to use serialize instead of serializejson
it works fine (with deserializejson I dod not try plain deserialize), if I
check the data directly in the database the only diffrence is that the
serializejson method uses double quotes and the serialize uses single
quotes, so I tried a deserializeJson(replace(sVars.cVal, "", “”, “ALL”))
and this works on original data, I found this most baffling

is this bug in deserializeJson?

Regards

GX

If data is your original variable name, does deserializeJson(
serializeJson(data)) work ?

The problem is probably introduced by the database storage step. Comparing
serializeJson(data) with the string stored in the database will give you a
better idea of what the issue could be.

Thanks,
JeanOn Mon, Mar 30, 2015 at 8:11 AM, <@mailme.gx> wrote:

Hi All

I came across a strage issue today, when storing data in a database I use
serializejson when I retrieve it I use deserializejson
for some reason I am getting “invalid construct” when trying to
deserializejson if I change this to use serialize instead of serializejson
it works fine (with deserializejson I dod not try plain deserialize), if I
check the data directly in the database the only diffrence is that the
serializejson method uses double quotes and the serialize uses single
quotes, so I tried a deserializeJson(replace(sVars.cVal, "", “”, “ALL”))
and this works on original data, I found this most baffling

is this bug in deserializeJson?

Regards

GX


You received this message because you are subscribed to the Google Groups
“Lucee” group.
To unsubscribe from this group and stop receiving emails from it, send an
email to lucee+unsubscribe@googlegroups.com.
To post to this group, send email to lucee@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/lucee/d40982ca-97c3-490d-bb26-aba72e7dc800%40googlegroups.com
https://groups.google.com/d/msgid/lucee/d40982ca-97c3-490d-bb26-aba72e7dc800%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

Like Jeroen said, use serializeJson instead of serialize in the cfquery
block.

Thanks,
JeanOn Mon, Mar 30, 2015 at 12:29 PM, <@mailme.gx> wrote:

Jean, when i compare them the only diffrence is single quotes as opposed
to double quotes

On Monday, March 30, 2015 at 11:15:14 AM UTC+3, jmoniatte wrote:

Maybe compare the JSON string stored in the database with the one you get
back from the query in your code. Are they identical?

Thanks,
Jean

On Mon, Mar 30, 2015 at 10:11 AM, mail...@gmail.com wrote:

jmoniatte,

Thanks for the input

I did the test you suggested, it has something to do with database
because this works fine no errors:

Im doing a normal insert into a postgresql database as such

            <cfquery name="sVars.qData"

datasource=“#request.MQ.oAuth.getOperatorDatasource()#”>
insert into mq_gsdata (operator_id, data) values(
,

);

and the select is strait forward too, the even stranger thing is that I
do similar things im my app elsewhere and I have not run into this issue
yet, maybe it has to do woth preservesinglequotes but im not using that
elsewhere either

Regards

GX

On Monday, March 30, 2015 at 10:56:47 AM UTC+3, jmoniatte wrote:

If data is your original variable name, does deserializeJson(
serializeJson(data)) work ?

The problem is probably introduced by the database storage step.
Comparing serializeJson(data) with the string stored in the database
will give you a better idea of what the issue could be.

Thanks,
Jean

On Mon, Mar 30, 2015 at 8:11 AM, mail...@gmail.com wrote:

Hi All

I came across a strage issue today, when storing data in a database I
use serializejson when I retrieve it I use deserializejson
for some reason I am getting “invalid construct” when trying to
deserializejson if I change this to use serialize instead of serializejson
it works fine (with deserializejson I dod not try plain deserialize), if I
check the data directly in the database the only diffrence is that the
serializejson method uses double quotes and the serialize uses single
quotes, so I tried a deserializeJson(replace(sVars.cVal, "", “”,
“ALL”)) and this works on original data, I found this most baffling

is this bug in deserializeJson?

Regards

GX


You received this message because you are subscribed to the Google
Groups “Lucee” group.
To unsubscribe from this group and stop receiving emails from it, send
an email to lucee+un...@googlegroups.com.
To post to this group, send email to lu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/
msgid/lucee/d40982ca-97c3-490d-bb26-aba72e7dc800%40googlegroups.com
https://groups.google.com/d/msgid/lucee/d40982ca-97c3-490d-bb26-aba72e7dc800%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.


You received this message because you are subscribed to the Google
Groups “Lucee” group.
To unsubscribe from this group and stop receiving emails from it, send
an email to lucee+un...@googlegroups.com.
To post to this group, send email to lu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/
msgid/lucee/e28d742e-9d5b-471f-be58-6e143bf5422f%40googlegroups.com
https://groups.google.com/d/msgid/lucee/e28d742e-9d5b-471f-be58-6e143bf5422f%40googlegroups.com?utm_medium=email&utm_source=footer
.

For more options, visit https://groups.google.com/d/optout.


You received this message because you are subscribed to the Google Groups
“Lucee” group.
To unsubscribe from this group and stop receiving emails from it, send an
email to lucee+unsubscribe@googlegroups.com.
To post to this group, send email to lucee@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/lucee/0a0cecf8-b980-4a0f-9afb-34e335446ee3%40googlegroups.com
https://groups.google.com/d/msgid/lucee/0a0cecf8-b980-4a0f-9afb-34e335446ee3%40googlegroups.com?utm_medium=email&utm_source=footer
.

For more options, visit https://groups.google.com/d/optout.