diff options
author | Damien George <damien.p.george@gmail.com> | 2014-09-17 22:56:34 +0100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-09-17 22:56:34 +0100 |
commit | 612045f53f7e5edf9faa359ee9ee52d490d58000 (patch) | |
tree | a021612e31ff6275246514405c4a8421c6eff5d7 /py/objlist.c | |
parent | 8a9b999f1c9a0edf84b2507940efb8deaaa380b8 (diff) | |
download | micropython-612045f53f7e5edf9faa359ee9ee52d490d58000.tar.gz micropython-612045f53f7e5edf9faa359ee9ee52d490d58000.zip |
py: Add native json printing using existing print framework.
Also add start of ujson module with dumps implemented. Enabled in unix
and stmhal ports. Test passes on both.
Diffstat (limited to 'py/objlist.c')
-rw-r--r-- | py/objlist.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/py/objlist.c b/py/objlist.c index 59390f371f..789a1600d3 100644 --- a/py/objlist.c +++ b/py/objlist.c @@ -49,12 +49,15 @@ STATIC mp_obj_t list_pop(mp_uint_t n_args, const mp_obj_t *args); STATIC void list_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t o_in, mp_print_kind_t kind) { mp_obj_list_t *o = o_in; + if (!(MICROPY_PY_UJSON && kind == PRINT_JSON)) { + kind = PRINT_REPR; + } print(env, "["); for (mp_uint_t i = 0; i < o->len; i++) { if (i > 0) { print(env, ", "); } - mp_obj_print_helper(print, env, o->items[i], PRINT_REPR); + mp_obj_print_helper(print, env, o->items[i], kind); } print(env, "]"); } |