Skip to main content
Participant
May 1, 2013
Question

error cf with deserializeJSON

  • May 1, 2013
  • 1 reply
  • 1340 views

Hi everyone,

I have a problem while using the function deserializeJSON.

I have a request looking like this :

Request: {   'config': {   'bgSubtractor': {   'config': {   'learningRate': 1e-06,

                                                    'mogHistory': 52,

                                                    'mogSigmaSquared': 80.456140350877},

                                      'input': {   'image': 'blur.image'},

                                      'type': 'BGSubtractor'},

                  'blur': {   'config': {   'size': 3.0},

                              'input': {   'image': 'cropArea.image'},

                              'type': 'MedianBlur'},

                  'cropArea': {   'config': {   'rect': '{meta.areaSampleRect}'},

                                  'input': {   'image': 'video.image'},

                                  'type': 'Crop'},

                  'cropMaskBGSub': {   'config': {   'rect': '{meta.motionSampleRect}'},

                                       'input': {   'image': 'bgSubtractor.image'},

                                       'type': 'Crop'},

                  'cropMotion': {   'config': {   'rect': '{meta.motionSampleRect}'},

                                    'input': {   'image': 'cropArea.image'},

                                    'type': 'Crop'},

                  'dataSaver': {   'config': {   'columns': [   'frameCount', ..... etc

but when i tried to deserialized it I got the error below. I know it's because I have this float as a scientific notation "1e-06". When I removed it, it's working fine.

Is there anyway to resolve this problem?

Thanks,

Kavinsky69

{"ExtendedInfo":"","Message":"Invalid Syntax Closing [}] not found","Detail":"","additional":{},"Extended_Info":"","ErrNumber":0,"TagContext":[{"id":"??","template":"\/home\/ubuntu\/lib-src\/railo-4\/webroot\/optimizer\/index.cfm","codePrintPlain":"130: \t

#qMasterData.request#<\/pre> \n131: \t<\/cfoutput>\t\n132: \t\n133: \t\n134: \t
#qMasterData.request#<\/pre>\n","column":0,"line":132,"raw_trace":"optimizer.index_cfm$cf.call(\/home\/ubuntu\/lib-src\/railo-4\/webroot\/optimizer\/index.cfm:132)","type":"cfml","codePrintHTML":"130: \t<pre style="white-space: normal">#qMasterData.request#<\/pre> 
\n131: \t<\/cfoutput>\t
\n132: \t<cfset json = deserializeJSON(qMasterData.request) ><\/b>
\n133: \t<cfoutput>
\n134: \t<pre style="white-space: normal">#qMasterData.request#<\/pre>
\n"}],"ErrorCode":"0","StackTrace":"Invalid Syntax Closing [}] not found\n\tat

    This topic has been closed for replies.

    1 reply

    May 1, 2013

    I'm using Coldfusion 9 and it works fine for me.

    isNumeric(1e-06);  // true
    jsn = '{"string":"foo","number":123.456,"scientific":1e-06}';
    struct = deserializeJSON(jsn);
    writedump(struct);
    

    You can try to run isNumeric(1e-06) to double check if it's picking it up as a number in scientific notation.

    As I said, it works fine for me in Coldfusion, but it might be a bug in Railo: https://groups.google.com/forum/?fromgroups=#!topic/railo/tzwII5e0caQ

    Participant
    May 2, 2013

    Thanks for your answer.

    I'm running on ColdFusion 10.

    I checki with isNumeric on railo and for isNumeric("1e-06") is given me false but for isNumeric("1e06") is sending me true.

    So I guess you're maybe right and t might be a railo bug

    Participant
    May 2, 2013

    Finally i found what the error was if your request look like that

    json = '{"string":"foo","number":123.456,"scientific":1e-06}

    it gives you the error but if the request is

    json = '{"string":"foo","number":123.456,"scientific":"1e-06"}

    it's working fine.

    So I guess it sends the error as the "e-" is not recognize as a flot but as string