LibDocument

image-alt

Document and Trie Processing.


json.h File Reference

Version: 0.1.1

JSON and LDJSON readers that create annotated document representations. More…

#include "document.h"
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

Go to the source code of this file.

Enumerations

ldoc_json_kwval_t { LDOC_JSON_NKW = 0, LDOC_JSON_NULL, LDOC_JSON_TRUE, LDOC_JSON_FALSE }
 JSON keyword types. More...
 
ldoc_json_prs_err_t { LDOC_JSON_OK = 0, LDOC_JSON_INV }
 JSON parsing errors. More...
 

Functions

ldoc_doc_tldoc_json_read (char *json, size_t len, off_t *err)
 Converts a single JSON object in string form to a document. More…
 
ldoc_doc_tldoc_ldjson_read (char *ldj, size_t len, off_t *err, off_t *nxt)
 Converts a JSON objects – one of many – in string form to a document. More…
 

Detailed Description

JSON and LDJSON readers that create annotated document representations.

The JSON/LDJSON readers can also handle JSON Linked Data (JSON-LD) objects.

Enumeration Type Documentation

JSON keyword types.

Enumerator

LDOC_JSON_NKW

Not a JSON keyword ("no keyword").

LDOC_JSON_NULL

JSON "null" value.

LDOC_JSON_TRUE

JSON "true" value.

LDOC_JSON_FALSE

JSON "false" value.

JSON parsing errors.

Enumerator

LDOC_JSON_OK

No parsing errors.

LDOC_JSON_INV

Invalid JSON object.

Function Documentation

ldoc_doc_t* ldoc_json_read (char *json, size_t len, off_t *err)

Converts a single JSON object in string form to a document.

Parameters and Return Value
json
JSON object as a string.
len
Length of the string json.
err
If a parsing error is encountered and the pointer err is not NULL, then *err is set to the character offset at which the parsing error was occurred.
Returns
A document object representing the JSON object provided as string json, or LDOC_DOC_NULL if a parsing error was encountered.

ldoc_doc_t* ldoc_ldjson_read (char *ldj, size_t len, off_t *err, off_t *nxt)

Converts a JSON objects – one of many – in string form to a document.

This function can be used to convert line-delimited JSON (LDJSON) objects to LibDocument documents.

Parameters and Return Value
json
JSON object as a string.
len
Length of the string json.
err
If a parsing error is encountered and the pointer err is not NULL, then *err is set to the character offset at which the parsing error was occurred.
nxt
If not NULL, then *nxt will be set to the character offset at which the next JSON object (purportedly) begins.
Returns
A document object representing the JSON object provided as string json, or LDOC_DOC_NULL if a parsing error was encountered.