Skip to content

Libraries JSONExport

Jakub Jakubiec edited this page Feb 24, 2014 · 1 revision
Library Extends Path
JSONExport /application/libraries/JSONExport.php

This library handles nilai data export to JSON file.

Export should be able to handle data regardless of number of marks to export. So data are processed in packs, saved to temporary file and served as attachment in the end. JSON file format has to be well defined in order to import it later line-by-line, without need to load it as a whole into memory.

Constants

Constant Type Default Description
FLUSH_ON_WRITE boolean false Decides if every write to the file should result in flushing it
JSON_START string {\n JSON start character
JSON_END string } JSON end character
JSON_MAIN_OBJECT_START string "export": {\n Json export object header
JSON_ARRAY_START string [\n JSON Array Start character
JSON_ARRAY_END string ] JSON Array End character

Methods

__construct - Public

Called automatically, creates temporary file to put data in.


__destruct - Public

Called automatically, removes temporary file with data.


addMark - Public

Add selected mark to export file

Arguments

Variable Type Default Required Description
$markData stdObj N/A Yes Single mark data with all dependent information about labels, tags etc.

addMeta - Public

Adds metadata about export file, like number of records, file format revision etc. Data comes in key/value pair format.

Arguments

Variable Type Default Required Description
$metaName string N/A Yes Metadata key
$metaValue string N/A Yes Metadata value

getFileForOutput - Public

Marks file as completed and returns file handle to the file containing data.