• Hi,
    I just came over a an odd situation:
    I have a structure myData

    var myData={
      'A1':{name:'..'},
      'A2':{name:'..'},
      'A 3':{name:'..'}
    };
    

    I can call myData.A1 as well as myData.A2 but of course myData.A 3 fails because of the space.
    Is it possible that Espruino interpreter should reject attributes containing spaces in the name?

  • I believe it's still entirely valid JS...

    You can just reference them with myData['A 3'] so it's not a big problem?

  • Correct, it is not a big problem. I didn't know JS was so permissive.
    Thanks for quick reply, @Gordon!

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

[SOLVED] JSON attribute accepts spaces in name but cannot be addressed

Posted by Avatar for Jean-Philippe_Rey @Jean-Philippe_Rey

Actions