Server Side simple quote vs double quotes

Server Side simple quote vs double quotes

KiooKioo Posts: 9Questions: 0Answers: 0
edited January 2010 in General
Hello all,
Hello Allan,

I have a little issue with the datatable 1.6 with the server side mode.
Datable with response using simple quote doesn't work.

Short example 1:
[code]
{'sEcho': 1,
'iTotalRecords': 11,
'iTotalDisplayRecords': 11,
'sColumns': 'name1,name2,name3',
'aaData': [['93','2009-10-01 12:10:22','Kioo']]
}
[/code]

But the same example with double quote is great.
Short example 2:
[code]
{"sEcho": 1,
"iTotalRecords": 11,
"iTotalDisplayRecords": 11,
"sColumns": "name1,name2,name3",
"aaData": [["93","2009-10-01 12:10:22","Kioo"]]
}
[/code]

I really need simple quote (like example 1) to push html and some others stuffs.


Can you help me, please ?


Regards.
Sorry for my poor english.

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Single quotes are not valid JSON (run your code through jsonlint.com for example). I suspect this is way it is breaking. Why do you "need" single quotes? Can't you just escape single quotes inside the string?

    Allan
  • KiooKioo Posts: 9Questions: 0Answers: 0
    edited January 2010
    Simply to inject html in the result.

    But I can't escape my string due to xsl transformation. The result database is transform in xsl before send to the client.

    Or I didn't find how to escape in xsl with a compatibility with jSon. :)

    In fact, my code looks like this:
    [code]

    {
    'sEcho': 1,
    'iTotalRecords': ,
    'iTotalDisplayRecords': ,
    'sColumns': 'name1,name2,name3',
    'aaData': [

    ['',
    '',
    'go to'
    ],
    ]}


    [/code]

    Thank you for your help.
  • KiooKioo Posts: 9Questions: 0Answers: 0
    Works great with:

    [code]

    {
    "sEcho": 1,
    "iTotalRecords": ,
    "iTotalDisplayRecords": ,
    "sColumns": "name1,name2,name3",
    "aaData": [

    ["",
    "",
    "go to"
    ],
    ]}


    [/code]

    Thanks Allan, JSON must have double quote.
  • KiooKioo Posts: 9Questions: 0Answers: 0
    Another way...

    jQuery 1.4 with the last firefox uses the native JSON parser.
    I tried to disable it with the next command

    [code]
    /* this should be the very first JavaScript inclusion file */
    window.JSON = null;
    [/code]

    But it doesn't work too.
  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Hi Kioo,

    I suggest posting this question in an XSLT forum. I'm no expert on the subject I'm sorry to say (although have used a 'replace' function in XSL before for what little I have done, so it should be possible to escape the strings). Sorry I can't help more.

    Regards,
    Allan
This discussion has been closed.