Select your language

Sign up

JSON (JavaScript Object Notation) is a text format for exchanging structured data. Joomla and its extensions use JSON in APIs, AJAX responses and settings where the particular interface specifies it.

Structure and syntax

Objects contain name-value pairs, while arrays contain ordered values. Values can be objects, arrays, strings, numbers, true, false or null. Property names and strings use double quotation marks.

Standard JSON does not allow comments, trailing commas, functions, undefined or NaN. It resembles part of JavaScript syntax but is not arbitrary executable code.

Handling Joomla data

Use a standard parser, then validate the expected structure, types and limits. Successful parsing does not mean the data is suitable for the application or authorised for the user.

With Joomla APIs, inspect HTTP status and Content-Type before processing. An HTML error page instead of JSON often explains a parser failure. Joomla PHP extensions should use library encoders rather than building JSON through string concatenation.

Conclusion

JSON transfers data between systems. Reliable use requires valid syntax, response structure checks and error handling.

Mentions:

JavaScript, XML

Newsletter Subscription
Enter your email address and we will keep you updated!

Joomla.center is not affiliated with or endorsed by the Joomla!® Project or Open Source Matters. The Joomla!® name and logo is used under a limited license granted by Open Source Matters, the trademark holder in the United States and other countries.