Chris Davenport/JData

From Joomla! Documentation

< User:Chris Davenport
Revision as of 17:48, 7 December 2011 by Chris Davenport (talk | contribs) (Added JDataAdapterJson and JDataConnectorHttp.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

JData is a new set of classes that provides a data handling library for the Joomla Platform. The aim is to provide a set of tools to make it easier to construct input and output data handling code.

Ideally you should be able to write code that can process data without having to know anything about the format in which it was presented. So, for example, an application written using the data handling library to read and process data from an XML file should not require anything more than trivial amendment to run with the same data presented as a CSV file.

These classes are intended to make the task of writing data handling applications as quick and painless as possible. As such their performance is of secondary concern. If you are processing large amounts of data where performance is an issue then you should look at constructing a custom data handler instead of using these classes.

The data handling classes will take care of the mechanics of parsing the input data and the assembly and output of data records.

Currently there is an XML adapter that uses a stream parser to input documents of arbitrary size with minimal impact on memory, a CSV parser that uses the first line of the file to define field names, and a database table output adapter that will automatically add columns to the chosen table as required.

The code is in libraries/joomla/data in my Github repository.

For more information see How to use the JData classes


A handler is the engine that drives the task of processing the data. You will need to create a class that extends a data handler class with methods that are specific to the data you are processing.

This handler can process data from a single input adapter and output to multiple output adapters.


Adapters deal with data formats. In input mode an adapter identifies the fields and records within the input data and passes them to the handler, while in output mode an adapter takes arrays of fields and converts them into records appropriate for the output format.

Read and/or write comma-separated (CSV) files.
Read and/or write JSON-encoded data.
Write to a database table. Read from a database table is not done yet.
Read and/or write XML files. Reading and parsing of XML is done using a stream parser so it can handle arbitrarily large files.


Connectors deal with physically moving data from an adapter to whatever physical storage mechanism is being used. Not all adapters can or need to make use of this level of abstraction. For example, the XML adapter in input mode opens an XML file directly and (at least currently) cannot make use of these connectors.

This connector simply outputs the data to standard output using PHP echo. Cannot be used in input mode.
Reads and/or writes data to a file on a physical filesystem.
Reads data from a URI over HTTP.