Support » Plugin: JSON API » Difficulty excluding fields from data returned by introspector methods

  • Hi there

    Great plugin.

    I am writing a custom controller, and want to only include/exclude certain data from the data returned, such as excluding the ‘author’ info.

    I have got my custom controller working, and I am trying the following

    return $json_api->introspector->get_posts();

    which works fine and returns all the posts data as JSON.

    However, I want to exclude the ‘author’ info, and am modifiying the above code to be:

    return $json_api->introspector->get_posts(array(‘exclude’ => ‘author’));

    However, it doesn’t work, returning all the same fields again.

    Also, if I try any basic statements like the following, I also don’t get a subset of the posts data:
    return $json_api->introspector->get_posts(array(‘exclude’ => ‘title_plain’));
    return $json_api->introspector->get_posts(array(‘include’ => ‘title_plain’));
    return $json_api->introspector->get_posts(array(‘query’ => ‘include=title_plain’));

    What am I missing? I’ve tried so many combinations maybe I’ve missed something simple.

    Does the ‘core’ controller need to be activated at all? Whether it is or not seems to make no difference.

    If anyone could help I’d greatly appreciate it.

Viewing 2 replies - 1 through 2 (of 2 total)
  • No need to create custom controller. Append “exclude” query parameter in your URL with comma separated values.


    Hi thanks for your response.

    You’re missing the point though, or perhaps I didn’t explain myself properly.

    I need to create a custom controller to output custom data (from a custom plugin), and I want to include some of the data (but not all) from the internal ‘get_posts’ method in a ‘node’ of the JSON output as well. But filtering the output from ‘get_posts’ seems to have no effect, whereas based on the documentation I believe it should.


Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Difficulty excluding fields from data returned by introspector methods’ is closed to new replies.