miller/c/input/mlr_json_adapter.h
2017-03-01 16:45:58 -05:00

18 lines
868 B
C

#ifndef MLR_JSON_ADAPTER_H
#define MLR_JSON_ADAPTER_H
#include "input/json_parser.h"
#include "containers/lrec.h"
// Given parsed JSON, constructs a list of lrecs with string values pointing into the parsed JSON.
// This is done for efficiency, to avoid data copying. It also means the parsed JSON should not be
// freed until the lrecs are freed.
//
// Default behavior on arrays is to fatal. There is a command-line option to skip them. Miller
// doesn't have an array object in its DSL, only maps, and converting JSON arrays to int-keyed maps
// poses problems of irreversibility. (Namely, 'mlr --json cat foo.json' when foo.json contains
// arrays would result in output differing from input.)
int reference_json_objects_as_lrecs(sllv_t* precords, json_value_t* ptop_level_json, char* flatten_sep,
int json_skip_arrays_on_input);
#endif // MLR_JSON_ADAPTER_H