- edited description
HTTPServer returns strings with quotes around the value in Snap!
Issue #225
resolved
When I retrieve a Microblocks string value from Snap!, using getVar, it arrives with “ “ around it
This was with microbit running Microblocks
Comments (3)
-
reporter -
repo owner Yes, that is the correct behavior. The same is true if you retrieve the value with a browser HTTP request. The quotes tell you that the value is a string. Without the convention, the client would not be able to distinguish between boolean values true and false and the strings "true" and "false" or between a string containing digits and an integer.
When you set variables, you can omit the double quotes unless they are needed to disambiguate between booleans or numbers and a string.
Here's the help message from the HTTP server:
MicroBlocks HTTP Server / - this help text /getVar/URL_encoded_var_name - get variable value /setVar/URL_encoded_var_name/value - set variable value (value is: true, false, an integer, or a URL-encoded string (up to 800 bytes)) (double-quote strings that would otherwise be treated as a boolean or integer such as "true", "false", or "12345") /broadcast/URL_encoded_message - broadcast message to board /getBroadcasts - get broadcasts from board, (URL-encoded strings, one per line) /varNames - get all variable names, one per line /board - get the board type; return "none" if no board is connected Lists and byte arrays are not supported, although getVar reports them as they would be shown by the "say" block
-
repo owner - changed status to resolved
- Log in to comment