Add data to JSON generated by views_datasource I'm using "views datasource" to output a view as JSON - for each views row it's creating a JSON object with the fields as string/value pairs - all those objects are in an array which is the value to a string specified by the "Root object name" in the view's format settings. It looks like this:

{
  "nodes":[
    {
      "nodeid":"1",
      "title":"foo"
    },
    {
      "nodeid":"2",
      "title":"bar"
    }
  ]
}


Now I need to add another string/value pair to the main JSON object so it looks like this:

{
  "nodes":[
    {
      "nodeid":"1",
      "title":"foo"
    },
    {
      "nodeid":"2",
      "title":"bar"
    }
  ],
  "total_nodes":"2",
  "some_other_stuff":"here"
}


In another question I found out how I could add elements to the view's results but now I need to add elements "next to" the view's results. I just don't know where I need to put my code. Can anyone point me to a hook that would do the trick?
You could implement something in the view template for the JSON display. 

The correct file to modify seems to be views-views-json-style-simple.tpl.php. 

You have to copy it to your theme's template folder (usually template's root directory, or template subdirectory) and add the necessary data to the $json variable before the correct print $json statement.