Skip to content

Libraries JSONExport

Jakub Jakubiec edited this page Feb 24, 2014 · 1 revision
LibraryExtendsPath
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

ConstantTypeDefaultDescription
FLUSH_ON_WRITEbooleanfalseDecides if every write to the file should result in flushing it
JSON_STARTstring{\nJSON start character
JSON_ENDstring}JSON end character
JSON_MAIN_OBJECT_STARTstring"export": {\nJson export object header
JSON_ARRAY_STARTstring[\nJSON Array Start character
JSON_ARRAY_ENDstring]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

VariableTypeDefaultRequiredDescription
$markDatastdObjN/AYesSingle 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

VariableTypeDefaultRequiredDescription
$metaNamestringN/AYesMetadata key
$metaValuestringN/AYesMetadata value

getFileForOutput - Public

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

Clone this wiki locally