7 – Alter Services JSON Response


I have created a view to render all taxonomy terms and displayed it through a service. I have also created an endpoint in the service module to hit the url through firefox add-on RESTer to test the JSON response. Now I want to alter the JSON response to add more key and value programatically. I am sharing all my resources which I have used but nothing changed

This is my view

This is my JSON response so far:

(
        {
            "Name": "<a href="/forum/1">General discussion</a>",
            "tid": "1",
            "description": ""
        },
        {
            "Name": "<a href="/forum/2">Miscellaneous - Hangout forums</a>",
            "tid": "2",
            "description": ""
        },
        {
            "Name": "<a href="/forum/3">Debt Management and Debt Consolidation</a>",
            "tid": "3",
            "description": ""
        },
        {
            "Name": "<a href="/forum/6">Archive</a>",
            "tid": "6",
            "description": ""
        }

But I want my JSON like this:

(
        {
            "Name": "<a href="/forum/1">General discussion</a>",
            "tid": "1",
            "description": "",
            "MY_CUSTOM_KEY": "MY CUSTOM VALUE"
        },
        {
            "Name": "<a href="/forum/2">Miscellaneous - Hangout forums</a>",
            "tid": "2",
            "description": "",
            "MY_CUSTOM_KEY": "MY CUSTOM VALUE"
        },
        {
            "Name": "<a href="/forum/3">Debt Management and Debt Consolidation</a>",
            "tid": "3",
            "description": "",
            "MY_CUSTOM_KEY": "MY CUSTOM VALUE"
        },
        {
            "Name": "<a href="/forum/6">Archive</a>",
            "tid": "6",
            "description": "",
            "MY_CUSTOM_KEY": "MY CUSTOM VALUE"
        }
)

I had used hook_views_pre_render to alter the JSON but couldn’t get it:

function MY_MODULE_views_pre_render(&$view) {
    if($view->name == 'forum_list') {
        $results = &$view->result;
        foreach($results as $key=>$value) {
            $value->MY_CUSTOM_KEY= "MY CUSTOM VALUE";
        }
    }
}