Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>No, there's no difference between <code>"</code> and <code>'</code> for quoting strings other than that you can use <code>"</code> without escaping it inside a string quoted with <code>'</code> and vice-versa. But I don't think that (the title of your question) actually has anything to do with the problem you're having.</p> <p>Re your edit, if you want to ensure that there are no characters with the value 0 or 255 in the string, you can do that like this:</p> <pre><code>data = data.replace(/[\u0000\u00ff]/g, ''); </code></pre> <p>...before passing it to <code>eval</code>. And it sounds like you might want to do that, since your thing is saying it's received 37 bytes but the string is only 36 characters long and doesn't use any characters requiring two bytes (or perhaps it just has a space at the end I can't see).</p> <p><strong>Off-topic</strong>: It's best not to use <code>eval</code> to deserialize JSON. Instead, use a library that handles it directly. Crockford has two different non-<code>eval</code> libs on <a href="https://github.com/douglascrockford/JSON-js" rel="nofollow">his github page</a>, one (json_parse.js) that uses a recursive-descent parser and another (json_parse_state.js) that uses a state machine. If you really, really want to use <code>eval</code> to parse JSON, take a look at his implementation in json2.js, which at least takes a couple of steps to weed out malicious stuff.</p> <p><strong>Off-topic 2</strong>: Re</p> <blockquote> <p>where <code>data = { "cmd": "setname", "params": "ok" }</code> (with quotes i suppose, because of typeof(data) being = string).</p> </blockquote> <p>We only use quotes to quote string literals in code; there are no quotes around actual string data itself in memory. If I do this:</p> <pre><code>var foo = "bar"; </code></pre> <p>...the string that <code>foo</code> points to consists entirely of the characters b, a, and r. There are no quotes; the quotes are only there in the code to tell the parser that what follows is a string literal.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload