Skip to content
This repository was archived by the owner on Nov 26, 2023. It is now read-only.

Commit 2a2201c

Browse files
committed
Bugfixes
- Bugfix: Updated the members function to fit EE6.x - Added json_pretty_print parameter for better readable output. Handy in the development stage - Code cleanup - Updated README
1 parent fc5be14 commit 2a2201c

File tree

4 files changed

+200
-119
lines changed

4 files changed

+200
-119
lines changed

README.markdown

+60-32
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Since legacy custom fields do not have their own table they will work fine eithe
1919

2020
***Fluid fieldtype***
2121

22-
Fluid fieldtype is not supported.
22+
Fluid fieldtype is not yet supported.
2323

2424
## Installation
2525

@@ -29,23 +29,27 @@ Fluid fieldtype is not supported.
2929

3030
### `xhr="yes"`
3131

32-
Set xhr to yes to only output data when an XMLHttpRequest is detected. Do not set this to yes if you are using JSONP, as JSONP requests are not true XHMLHttpRequests.
32+
Set `xhr` to yes to only output data when an XMLHttpRequest is detected. Do not set this to yes if you are using JSONP, as JSONP requests are not true XHMLHttpRequests.
3333

3434
### `terminate="yes"`
3535

36-
Set terminate to yes to terminate the template and output your json immediately, with Content-Type headers.
36+
Set `terminate=` to yes to terminate the template and output your json immediately, with Content-Type headers.
37+
38+
### `json_pretty_print="yes"`
39+
40+
For a better readable output. Combine with `terminate="yes"`. It's handy in the development stage.
3741

3842
### `fields="title|url_title"`
3943

4044
Specify which fields you wish to have in the array. Separate multiple fields by a pipe character. If you do not specify fields, you will get all of the default fields' data. The primary key (`entry_id` for entries, `member_id` for members) will always be present and cannot be suppressed by this parameter.
4145

4246
### `content_type="text/javascript"`
4347

44-
Set a custom Content-Type header. The default is "application/json", or "application/javascript" if using JSONP. Headers are only sent when terminate is set to "yes".
48+
Set a custom Content-Type header. The default is "application/json", or "application/javascript" if using JSONP. Headers are only sent when `terminate` is set to "yes".
4549

4650
### `jsonp="yes"`
4751

48-
Set jsonp to yes to enable a JSONP response. You must also specify a valid callback. You are encouraged to set terminate to yes when using JSONP.
52+
Set `jsonp` to yes to enable a JSONP response. You must also specify a valid callback. You are encouraged to set `terminate` to yes when using JSONP.
4953

5054
### `callback="yourCallbackFunction"`
5155

@@ -139,15 +143,15 @@ for (i in data) {
139143
}
140144
```
141145

142-
If you require a different output format for the date fields, set the date_format= parameter. This uses the php date() function. common formats include "U" (unix timestamp in seconds), "c" (ISO 8601) or "Y-m-d H:i" (2011-12-24 19:06).
146+
If you require a different output format for the date fields, set the `date_format=` parameter. This uses the php date() function. common formats include "U" (unix timestamp in seconds), "c" (ISO 8601) or "Y-m-d H:i" (2011-12-24 19:06).
143147

144148
## json:entries
145149

146150
```
147151
{exp:json:entries channel="news"}
148152
```
149153

150-
json:entries is a single tag, not a tag pair. Use channel:entries parameters to filter your entries.
154+
`json:entries` is a single tag, not a tag pair. Use channel:entries parameters to filter your entries.
151155

152156
#### json:entries Default Fields
153157

@@ -174,18 +178,26 @@ This will add categories to the entries response
174178

175179
##### `show_category_group="1|2"`
176180

177-
When paired with show_categories="yes", this will display only categories from the specified groups.
181+
When paired with `show_categories="yes"`, this will display only categories from the specified groups.
178182

179183
#### json:entries Custom Fields
180184

181185
Most custom fields will just return the raw column data from the `exp_channel_data` database table. The following fieldtypes will provide custom data. You *must* specify the `channel` parameter to get custom fields.
182186

183-
##### Matrix
187+
##### Date
184188

185-
The data will include an array of Matrix rows, including the row_id and the column names:
189+
The data will be the Unix timestamp, accurate to milliseconds. This is because the native JavaScript Date object accepts a millisecond-based timestamp in its constructor.
186190

187191
```
188-
your_matrix_field: [
192+
your_date_field: 1385661660000
193+
```
194+
195+
##### Grid
196+
197+
The data will include an array of Grid rows, including the row_id and the column names:
198+
199+
```
200+
your_grid_field: [
189201
{
190202
row_id: 1,
191203
my_col_name: "foo",
@@ -199,19 +211,21 @@ your_matrix_field: [
199211
]
200212
```
201213

202-
##### Grid
214+
##### File Grid (EE v5.1+)
203215

204-
The data will include an array of Grid rows, including the row_id and the column names:
216+
The data will include an array of File Grid rows including the row_id, the file and the optional extra column names:
205217

206218
```
207-
your_grid_field: [
219+
your_file_grid_field: [
208220
{
209221
row_id: 1,
222+
file: "URL-to-your-file",
210223
my_col_name: "foo",
211224
other_col_name: "bar"
212225
},
213226
{
214227
row_id: 2,
228+
file: "URL-to-your-file",
215229
my_col_name: "baz",
216230
other_col_name: "qux"
217231
}
@@ -226,15 +240,7 @@ The data will include an array of related entry IDs:
226240
your_relationships_field: [1, 2]
227241
```
228242

229-
##### Playa
230-
231-
The data will include an array of related entry IDs:
232-
233-
```
234-
your_playa_field: [1, 2]
235-
```
236-
237-
##### Assets
243+
##### Assets (not tested with JSON v2+)
238244

239245
```
240246
your_assets_field: [
@@ -289,7 +295,7 @@ your_assets_field: [
289295

290296
*NOTE: image manipulation urls are only available to Assets files store locally, not on Amazon S3 or Google Storage.*
291297

292-
##### Channel Files
298+
##### Channel Files (not tested with JSON v2+)
293299

294300
```
295301
your_channel_files_field: [
@@ -334,12 +340,31 @@ your_channel_files_field: [
334340
]
335341
```
336342

337-
##### Date
343+
##### Matrix (not tested with JSON v2+)
338344

339-
The data will be the Unix timestamp, accurate to milliseconds. This is because the native JavaScript Date object accepts a millisecond-based timestamp in its constructor.
345+
The data will include an array of Matrix rows, including the row_id and the column names:
340346

341347
```
342-
your_date_field: 1385661660000
348+
your_matrix_field: [
349+
{
350+
row_id: 1,
351+
my_col_name: "foo",
352+
other_col_name: "bar"
353+
},
354+
{
355+
row_id: 2,
356+
my_col_name: "baz",
357+
other_col_name: "qux"
358+
}
359+
]
360+
```
361+
362+
##### Playa (not tested with JSON v2+)
363+
364+
The data will include an array of related entry IDs:
365+
366+
```
367+
your_playa_field: [1, 2]
343368
```
344369

345370
## json:search
@@ -456,12 +481,17 @@ function yourCallbackFunction(data) {
456481

457482
## Changelog
458483

484+
### v.2.5.2
485+
486+
- Bugfix: Updated the `members` function to handle both legacy (pre EE4) and newer member data
487+
- Added `json_pretty_print` parameter for better readable output. Handy in the development stage
488+
- Code cleanup
489+
- Updated README
490+
459491
### v2.5.1
460492

461493
- Bugfix: Removed all remnants of fluid field data, since the Fluid fieldtype is not (yet) supported. The remnant data is unusable at this point. Working on support for Fluid fieldtype
462-
- Bugfix: Updated the `members` function to fit EE6.x
463494
- Changed `addon.setup.php` and cleaned it up
464-
- **Note:** not tested with Assets, Matrix, Playa and Channel Files fieldtypes/modules
465495

466496
### v2.5.0
467497

@@ -470,15 +500,13 @@ function yourCallbackFunction(data) {
470500
- Added support for File Grid fieldtype
471501
- Added support for legacy custom fields and data (EE2 and EE3 custom fields and data) for compatibility with upgraded versions of EE4+
472502
- Added `/system/user/addons/json/icon.png` for the EE6 control panel
473-
- **Note:** not tested with Assets, Matrix, Playa and Channel Files fieldtypes/modules
474503

475504
### v1.1.9
476505

477-
- EE3 compatibility
506+
- ExpressionEngine 3.x compatibility
478507
- Added relationships support for grids as per [ahebrank's](https://github.com/ahebrank) [commit](https://github.com/rsanchez/json/pull/65)
479508
- Added `/system/user/addons/json/addon.setup.php` for EE3
480509
- Added `/system/user/addons/json/README.md` for the add-on manual in the control panel (as of EE3)
481-
- **Note:** not tested with Assets, Matrix and Playa
482510

483511
## Attribution
484512

0 commit comments

Comments
 (0)