Pre sales - jBackend - Remove fields from json
-
dmeimaris
-
Topic Author
-
Offline
-
New Member
-
Less
More
-
Posts: 1
-
Thank you received: 0
-
-
8 years 10 months ago #5028
by dmeimaris
Hi, is it possible to remove some fields from json to make it faster and shorter? For example if I wanted to remove the metatags or the different dates?
Is it easy to do with some custom coding?
Please Log in or Create an account to join the conversation.
Less
More
-
Posts: 3194
-
Thank you received: 441
-
-
8 years 10 months ago - 8 years 10 months ago #5032
by admin
Of course you can do it with custom coding, and it's easy once you know what to change. In your example you need to "unset" some properties before to push out the response. Something like:
$items = $model->getItems();
foreach ($items as $key => $item) {
unset($items[$key]->published);
unset($items[$key]->access);
unset($items[$key]->ordering);
unset($items[$key]->params);
unset($items[$key]->checked_out);
unset($items[$key]->checked_out_time);
unset($items[$key]->editor);
}
$response['status'] = 'ok';
$response['total'] = count($items);
$response['categories'] = $items;
return true;
This is just an example of how to get what you need.
Kind regards,
Luigi
Last edit: 8 years 10 months ago by admin.
Please Log in or Create an account to join the conversation.
Time to create page: 0.176 seconds