Skip to content

Latest commit

 

History

History
59 lines (46 loc) · 1.4 KB

fORMJSON.wiki

File metadata and controls

59 lines (46 loc) · 1.4 KB

Table of Contents

fORMJSON

<<css mode="next" class="sidebar"></css>> (((

Class Resources <<toc></toc>>

 - '''<a href="/docs/fORMJSON">Class Documentation</a>'''
 - <a href="/api/fORMJSON">API Reference</a>
 - <a href="https://github.com/flourishlib/flourish-classes/blob/master/fORMJSON.php" target="_blank">Source Code</a>

<<toc></toc>>

ORM Classes <<toc></toc>>

 - fActiveRecord
 - fRecordSet

 - fORM
 - fORMColumn
 - fORMDatabase
 - fORMDate
 - fORMFile
 - '''fORMJSON'''
 - fORMMoney
 - fORMOrdering
 - fORMRelated
 - fORMSchema
 - fORMValidation

)))

The fORMJSON class is an ORM plugin to provide JSON encoding functionality to fActiveRecord and fRecordSet objects.

Enabling

To add the JSON encoding functionality for whole records and record sets, simply call the static method ::extend().

Usage

The fORMJSON class adds a `toJSON()` method to both fActiveRecord and fRecordSet. Calling `toJSON()` on a record will create a single JSON object with each column being the property name and the value being the value. Calling `toJSON()` on a record set will create an array of the record JSON objects.

When outputting JSON to a browser, it is best practice to include the appropriate `Content-Type` header by calling fJSON::sendHeader().