X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=lib%2Fovsdb-data.c;h=1781811917d2ee04df5f190da7622df3073a8e91;hb=6a6f8d167357a1f1751cdd54b9491c531a371ae1;hp=54ce72cf719c03baf3b3303df5f685f9fee8087c;hpb=0233401f12fe5ef8f9d63d660d2bd3f739766025;p=sliver-openvswitch.git diff --git a/lib/ovsdb-data.c b/lib/ovsdb-data.c index 54ce72cf7..178181191 100644 --- a/lib/ovsdb-data.c +++ b/lib/ovsdb-data.c @@ -1278,30 +1278,30 @@ struct json * ovsdb_datum_to_json(const struct ovsdb_datum *datum, const struct ovsdb_type *type) { - if (datum->n == 1 && !ovsdb_type_is_map(type)) { - return ovsdb_atom_to_json(&datum->keys[0], type->key.type); - } else if (type->value.type == OVSDB_TYPE_VOID) { + if (ovsdb_type_is_map(type)) { struct json **elems; size_t i; elems = xmalloc(datum->n * sizeof *elems); for (i = 0; i < datum->n; i++) { - elems[i] = ovsdb_atom_to_json(&datum->keys[i], type->key.type); + elems[i] = json_array_create_2( + ovsdb_atom_to_json(&datum->keys[i], type->key.type), + ovsdb_atom_to_json(&datum->values[i], type->value.type)); } - return wrap_json("set", json_array_create(elems, datum->n)); + return wrap_json("map", json_array_create(elems, datum->n)); + } else if (datum->n == 1) { + return ovsdb_atom_to_json(&datum->keys[0], type->key.type); } else { struct json **elems; size_t i; elems = xmalloc(datum->n * sizeof *elems); for (i = 0; i < datum->n; i++) { - elems[i] = json_array_create_2( - ovsdb_atom_to_json(&datum->keys[i], type->key.type), - ovsdb_atom_to_json(&datum->values[i], type->value.type)); + elems[i] = ovsdb_atom_to_json(&datum->keys[i], type->key.type); } - return wrap_json("map", json_array_create(elems, datum->n)); + return wrap_json("set", json_array_create(elems, datum->n)); } }