You are reading a single comment by @MrTimcakes and its replies. Click here to read the full conversation.
  • I'm parsing some JSON data from a web-server but in-case the server is down or returns something unexpected I want my code to do something safe. I tried checking if the data was undefined but that produces the error:

    Uncaught Error: Field or method "Hostname" does not already exist, and can't create it on undefined
    

    So next I tried data.hasOwnProperty but this isn't implemented in Espruino's implementation of JSON :/
    So I resorted to try catch which works just fine. Was this the right thing to do or should Espruino have some sort of has for JSON?

About

Avatar for MrTimcakes @MrTimcakes started