![]() |
Fun 0.41.5
The programming language that makes you have fun!
|
VM opcode snippet for parsing a JSON string into a Fun Value. More...
Go to the source code of this file.
Functions | |
| free_value (text) | |
| if (!s) | |
| json_tokener_free (tok) | |
| free (s) | |
| if (jerr !=json_tokener_success) | |
| push_value (vm, v) | |
| json_object_put (root) | |
Variables | |
| case | OP_JSON_PARSE |
| char * | s = value_to_string_alloc(&text) |
| struct json_tokener * | tok = json_tokener_new() |
| json_object * | root = json_tokener_parse_ex(tok, s, (int)strlen(s)) |
| enum json_tokener_error | jerr = json_tokener_get_error(tok) |
| else | |
| break | |
VM opcode snippet for parsing a JSON string into a Fun Value.
Implements the OP_JSON_PARSE instruction. Expects a string (or any value convertible to string) on the stack, parses it with json-c, converts the resulting json_object to a Fun Value and pushes it.
Build gating: compiled only when FUN_WITH_JSON is enabled. Otherwise the opcode consumes its argument and pushes Nil.
Stack effect (with FUN_WITH_JSON):
Errors and edge cases:
Definition in file parse.c.
| free | ( | s | ) |
| free_value | ( | text | ) |
| json_object_put | ( | root | ) |
| json_tokener_free | ( | tok | ) |
| push_value | ( | vm | , |
| v | ) |
| else |
| char* s = value_to_string_alloc(&text) |