コード例 #1
0
ファイル: output.c プロジェクト: ueno/groonga
void
grn_output_obj(grn_ctx *ctx, grn_obj *outbuf, grn_content_type output_type, grn_obj *obj, grn_obj_format *format)
{
  put_delimiter(ctx, outbuf, output_type);
  switch (output_type) {
  case GRN_CONTENT_JSON:
    grn_text_otoj(ctx, outbuf, obj, format);
    break;
  case GRN_CONTENT_TSV:
    grn_text_otoj(ctx, outbuf, obj, format);
    break;
  case GRN_CONTENT_XML:
    grn_text_otoxml(ctx, outbuf, obj, format);
    break;
  case GRN_CONTENT_MSGPACK :
    // todo
    break;
  case GRN_CONTENT_NONE:
    break;
  }
  INCR_LENGTH;
}
コード例 #2
0
ファイル: test-string.c プロジェクト: mooz/groonga
void
test_text_otoj(gconstpointer data)
{
  grn_obj object, json;
  grn_builtin_type type;
  const gchar *expected, *actual;

  GRN_TEXT_INIT(&json, 0);

  expected = gcut_data_get_string(data, "expected");
  type = gcut_data_get_int(data, "type");
  cut_trace(construct_object(data, type, &object));
  grn_text_otoj(&context, &json, &object, NULL);
  grn_obj_unlink(&context, &object);
  actual = cut_take_printf("%.*s",
                           (int)GRN_TEXT_LEN(&json), GRN_TEXT_VALUE(&json));
  grn_obj_unlink(&context, &json);
  cut_assert_equal_string(expected, actual);
}