mirror of
https://github.com/micropython/micropython.git
synced 2026-01-08 21:20:13 +01:00
py/objdict: Support ujson.dump() of OrderedDict objects.
Following CPython, OrderedDict are dumped with the syntax of dict.
This commit is contained in:
committed by
Damien George
parent
82d358510b
commit
1e87f11d3f
@@ -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, ")");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user