Viewing 2 replies - 1 through 2 (of 2 total)
  • You can use json_api_encode filter, like the following example:

    function turismogdf_remove_html_tags( $response ) {
    $post = ”;
    if( isset( $response[‘posts’] ) ) {
    foreach( $response[‘posts’] as $post ) {
    $post->content = strip_tags( $post->content );
    $post->excerpt = strip_tags( $post->excerpt );
    }
    } else if( $response[‘post’] ) {
    $post = $response[‘post’];
    $post->content = strip_tags( $post->content );
    $post->excerpt = strip_tags( $post->excerpt );
    }
    return $response;
    }
    add_filter( ‘json_api_encode’, ‘turismogdf_remove_html_tags’ );

    @cadu de Castro Alves

    Hey where do I place the following code?

    I’m creating a iOS app, and I am using this JSON plugin to convert wp data so the app can consume it. But when the app parses the JSON there many unwanted html tags and html special characters.

    I’m having a hard time customizing this plugin, for example this section:

    3.1. Output-modifying arguments.

    I want change these settings and see which will work best for me , but I don’t know where to insert these lines:

    json_unescaped_unicode
    json_encode

    Help me out please, can you point me to in the right direction here ?

    Thanks in Advance

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Modify JSON response’ is closed to new replies.