@@ -863,6 +863,31 @@ static void test_explain_statement() {
863
863
// DOCS NOTE: Others omitted for now
864
864
}
865
865
866
+ static void query_result_json () {
867
+ CBLDatabase * db = kDatabase ;
868
+
869
+ CBLError err ;
870
+ CBLQuery * query = CBLDatabase_CreateQuery (db , kCBLN1QLLanguage ,
871
+ FLSTR ("SELECT meta().id as id, name, city, type FROM _ LIMIT 10" ),
872
+ NULL , & err );
873
+
874
+ // tag::query-access-json[]
875
+ // NOTE: No error handling, for brevity (see getting started)
876
+
877
+ CBLResultSet * results = CBLQuery_Execute (query , & err );
878
+ while (CBLResultSet_Next (results )) {
879
+ FLDict result = CBLResultSet_ResultDict (results );
880
+ FLStringResult json = FLValue_ToJSON ((FLValue )result );
881
+ printf ("JSON Result :: %.*s\n" , (int )json .size , (const char * )json .buf );
882
+ FLSliceResult_Release (json );
883
+ }
884
+ CBLResultSet_Release (results );
885
+
886
+ // end::query-access-json[]
887
+
888
+ CBLQuery_Release (query );
889
+ }
890
+
866
891
static void create_full_text_index () {
867
892
CBLDatabase * db = kDatabase ;
868
893
@@ -1040,6 +1065,7 @@ int main(int argc, char** argv) {
1040
1065
select_join ();
1041
1066
group_by ();
1042
1067
order_by ();
1068
+ query_result_json ();
1043
1069
1044
1070
create_full_text_index ();
1045
1071
full_text_search ();
@@ -1058,23 +1084,13 @@ int main(int argc, char** argv) {
1058
1084
1059
1085
1060
1086
// tag::console-logging-db[]
1061
- Placeholder for code to increase level of console logging for kCBLLogDomainDatabase domain
1087
+ // Placeholder for code to increase level of console logging for kCBLLogDomainDatabase domain
1062
1088
// end::console-logging-db[]
1063
1089
1064
1090
// tag::console-logging[]
1065
- Placeholder for code to increase level of console logging for all domains
1091
+ // Placeholder for code to increase level of console logging for all domains
1066
1092
// end::console-logging[]
1067
1093
1068
1094
// tag::date-getter[]
1069
- Placeholder for Date accessors .
1070
-
1095
+ // Placeholder for Date accessors.
1071
1096
// end::date-getter[]
1072
-
1073
-
1074
- // tag::query-index[]
1075
- // placeholder
1076
- // end::query-index[]
1077
-
1078
- // tag::fts-index[]
1079
- // placeholder
1080
- // end::fts-index[]
0 commit comments