+static char *
+format_data(const struct json *json, const struct ovsdb_type *type)
+{
+ if (data_format == DF_JSON) {
+ return json_to_string(json, JSSF_SORT);
+ } else if (data_format == DF_STRING) {
+ struct ovsdb_datum datum;
+ struct ovsdb_error *error;
+ struct ds s;
+
+ error = ovsdb_datum_from_json(&datum, type, json, NULL);
+ if (error) {
+ return json_to_string(json, JSSF_SORT);
+ }
+
+ ds_init(&s);
+ ovsdb_datum_to_string(&datum, type, &s);
+ ovsdb_datum_destroy(&datum, type);
+ return ds_steal_cstr(&s);
+ } else {
+ NOT_REACHED();
+ }
+}
+