Skip to content

Commit 33bce0e

Browse files
committed
Reintroduce table name for embedded tables in xjson_plus format
1 parent e21209f commit 33bce0e

File tree

2 files changed

+23
-10
lines changed

2 files changed

+23
-10
lines changed

src/realm/to_json.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,11 +275,12 @@ void Obj::to_json(std::ostream& out, JSONOutputMode output_mode) const
275275
else {
276276
if (tt->is_embedded()) {
277277
if (output_mode == output_mode_xjson_plus) {
278-
out << "{ \"$embedded\": ";
278+
out << "{ \"$embedded\": {";
279+
out << "\"table\": \"" << tt->get_name() << "\", \"value\": ";
279280
}
280281
tt->get_object(obj_key).to_json(out, output_mode);
281282
if (output_mode == output_mode_xjson_plus) {
282-
out << "}";
283+
out << "}}";
283284
}
284285
}
285286
else {

test/expected_xjson_plus_embeddeddict1.json

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@
99
"$dictionary": {
1010
"key1": {
1111
"$embedded": {
12-
"int2": {
13-
"$numberLong": "111"
12+
"table": "table2",
13+
"value": {
14+
"int2": {
15+
"$numberLong": "111"
16+
}
1417
}
1518
}
1619
}
@@ -24,8 +27,11 @@
2427
},
2528
"embedded": {
2629
"$embedded": {
27-
"int2": {
28-
"$numberLong": "123"
30+
"table": "table2",
31+
"value": {
32+
"int2": {
33+
"$numberLong": "123"
34+
}
2935
}
3036
}
3137
},
@@ -43,15 +49,21 @@
4349
"$dictionary": {
4450
"key2": {
4551
"$embedded": {
46-
"int2": {
47-
"$numberLong": "222"
52+
"table": "table2",
53+
"value": {
54+
"int2": {
55+
"$numberLong": "222"
56+
}
4857
}
4958
}
5059
},
5160
"key3": {
5261
"$embedded": {
53-
"int2": {
54-
"$numberLong": "333"
62+
"table": "table2",
63+
"value": {
64+
"int2": {
65+
"$numberLong": "333"
66+
}
5567
}
5668
}
5769
}

0 commit comments

Comments
 (0)