Support » Plugin: JSON API » how to support another JSON flavour

  • Hello.

    Thanks for your great plugin, first of all: just works… and code is clean 😉

    What would be the best way to have the plugin serialize the WP data into another flavour of JSON (a.o. leaving most of the internal “technical” informations away, simplifying attachments links, dates, custom categories links and more…)?

    I want to feed my WP posts into a simile exhibit facet browsing view (see ao , and therefore need a custom JSON looking like below:

        "properties": {
            "taxonomy_sectors": {
                "label": "sector",
                "valueType": "CustomTaxonomyTerm"
        "items": [
                "label": "Some nice post",
                "title": "Some nice post",
                "type": "Post",
                "id": 346,
                "slug": "some-nice-post",
                "url": "http://local/2013/04/29/some-nice-post/",
                "content": "<p>Some nice post</p>\n<p>with long content</p>\n",
                "excerpt": "<p>Some nice post</p>\n",
                "date": "2013-04-29",
                "thumbnail": "",
                "tags": [
                "categories": [
                "taxonomy_sectors": [
                "author": "Coco"
                "label": "Construction",
                "description": "Building & Real-Estate",
                "slug": "construction",
                "id": 56,
                "url": "http://local/?sectors=construction",
                "type": "CustomTaxonomyTerm"
                "label": "Tourism",
                "description": "Hotels, Cafés, Festivals and more",
                "slug": "tourism",
                "id": 72,
                "url": "http://local/?sectors=tourism",
                "type": "CustomTaxonomyTerm"

    Official sample JSON file at – official documentation at

    Any pointer / suggestion is welcome.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Possible ways I see this is to
    1) implement my own model for posts, or
    2) to hack the generated associative array by putting a filter on ‘json_api_encode’ that would convert it to my needs or
    3) setting a JS callback that would to the same on the JSON.

    What is the best way? (could be something completely different too, let me know!)



    Looks like this might be doable with just a custom controller. Make a copy of the core controller, rename the class and other relevant parts and modify the formatting of the JSON to be the desired flavour.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘how to support another JSON flavour’ is closed to new replies.