aboutsummaryrefslogtreecommitdiff
path: root/py/objdict.c
diff options
context:
space:
mode:
authorAndrew Leech <andrew.leech@planetinnovation.com.au>2019-11-11 15:44:04 +1100
committerDamien George <damien.p.george@gmail.com>2019-11-13 13:51:18 +1100
commit1e87f11d3f2673ace3f36dd24bdc095bb25583e4 (patch)
treeb61f27ae789f16e5ca3a7dde9e5ed8cf8db7e07b /py/objdict.c
parent82d358510b38b092dac204786c193d8109dcf886 (diff)
py/objdict: Support ujson.dump() of OrderedDict objects.
Following CPython, OrderedDict are dumped with the syntax of dict.
Diffstat (limited to 'py/objdict.c')
-rw-r--r--py/objdict.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/py/objdict.c b/py/objdict.c
index 02a2346fd..7a43a8548 100644
--- a/py/objdict.c
+++ b/py/objdict.c
@@ -60,7 +60,7 @@ STATIC void dict_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_
if (!(MICROPY_PY_UJSON && kind == PRINT_JSON)) {
kind = PRINT_REPR;
}
- if (MICROPY_PY_COLLECTIONS_ORDEREDDICT && self->base.type != &mp_type_dict) {
+ if (MICROPY_PY_COLLECTIONS_ORDEREDDICT && self->base.type != &mp_type_dict && kind != PRINT_JSON) {
mp_printf(print, "%q(", self->base.type->name);
}
mp_print_str(print, "{");
@@ -83,7 +83,7 @@ STATIC void dict_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_
mp_obj_print_helper(print, next->value, kind);
}
mp_print_str(print, "}");
- if (MICROPY_PY_COLLECTIONS_ORDEREDDICT && self->base.type != &mp_type_dict) {
+ if (MICROPY_PY_COLLECTIONS_ORDEREDDICT && self->base.type != &mp_type_dict && kind != PRINT_JSON) {
mp_print_str(print, ")");
}
}