The primary reason for this extension is to control the fields being output to json_encode. It is very useful for generating a json output from twig template data. If you need an api for consuming externally, or even internally via Javascript frameworks such as Vue.js, React or Angular with Axios or other http libraries, this will make it easy for you.

This template will get all entries from the "news" section, grab just the title and body fields from each, and then output it to JSON.

{{ craft.entries.section('news').find() | hackjob(['title', 'body']) | json_encode() | raw }}

This template will get output a json array of all selected users and display the user fields and custom fields associated with their profile.

{% set users = craft.users.group('members').all() %} {{ users | hackjob(['id', 'username', 'name', 'email', 'photoUrl', 'customFieldOne', 'customFieldTwo']) | json_encode() | raw }}

Installation Instructions

To install this plugin, copy the command above to your terminal.

Active Installs
1
Version
1.0.0
License
MIT
Compatibility
Craft 3
Last release
November 17, 2018
Categories
Activity (30 days)
0
Closed Issues
0
Open Issues
0
Merged PRs
0
Open PRs