Commit 6332ecef authored by Sam Thursfield's avatar Sam Thursfield

tracker-extract: Add support for outputting resources as JSON-LD

This depends on tracker!3
parent 75ff6706
......@@ -71,7 +71,7 @@ The possible \fILEVEL\fR options are:
.B \-o, \-\-output-format\fR=<\fIFORMAT\fR>
Choose which format to use to output results. Supported formats are
\fIsparql\fR and \fIturtle\fR.
\fIsparql\fR, \fIturtle\fR and \fIjson-ld\fR.
......@@ -38,6 +38,12 @@ typedef enum {
typedef enum {
/* JSON and JSON_LD are treated as the same thing right now, but we could
* treat them differently if we wanted. also it's nice to be able to pass
* both 'json' and 'json-ld' to `tracker extract --output-format=`.
} TrackerSerializationFormat;
......@@ -662,9 +662,9 @@ tracker_extract_file (TrackerExtract *extract,
tracker_extract_get_metadata_by_cmdline (TrackerExtract *object,
const gchar *uri,
const gchar *mime,
tracker_extract_get_metadata_by_cmdline (TrackerExtract *object,
const gchar *uri,
const gchar *mime,
TrackerSerializationFormat output_format)
GError *error = NULL;
......@@ -731,6 +731,20 @@ tracker_extract_get_metadata_by_cmdline (TrackerExtract *object,
g_print ("%s\n", turtle);
g_free (turtle);
} else {
/* JSON-LD extraction */
char *json;
/* If this was going into the tracker-store we'd generate a unique ID
* here, so that the data persisted across file renames.
tracker_resource_set_identifier (resource, uri);
json = tracker_resource_print_jsonld (resource, NULL);
if (json) {
g_print ("%s\n", json);
g_free (json);
tracker_extract_info_unref (info);
......@@ -95,7 +95,7 @@ static GOptionEntry entries[] = {
N_("Force a module to be used for extraction (e.g. “foo” for “”)"),
N_("MODULE") },
{ "output-format", 'o', 0, G_OPTION_ARG_STRING, &output_format_name,
N_("Output results format: “sparql”, or “turtle”"),
N_("Output results format: “sparql”, “turtle” or “jsonld”"),
N_("FORMAT") },
{ "domain-ontology", 'd', 0,
G_OPTION_ARG_STRING, &domain_ontology_name,
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment