How do I edit the output of a field? I am creating REST API using Services Module in Drupal 7. 

I have created a View to Get lists of Groups. In this views, I have added a Field privacy which will tell if the group is Private or Public.

I am getting this Output if group is Private:

privacy":{"value":"1"},


and if the group is Public :

"privacy":[]


How can I edit the output of this field so that it become easier for app developer ? I want to have something like this in output :

For Private : privacy":{"value":"1"}, 
For Public  : privacy":{"value":"0"},


Or something like this which look good.
From the code you can use hook_services_request_postprocess_alter() to alter whatever you want from your response.

You can always use arguments to make your changes more specific:

function my_module_services_request_postprocess_alter($controller, $args, &amp;$result) {
  // In my response, I include the request string in the '_links' array.    
  // I can use this now to determine which resource was requested.  
  if (strpos($result-&gt;_links['self']['href'], 'api/1.0/widget')) {
    // Now I know I'm dealing with a widget request, so I'll
    // add the random string here...
    $result-&gt;String = "This is a string that I'm adding to the widget response";
  }
}


As result you can see in your response:

Array (
  [_links] =&gt; Array (
    [self] =&gt; Array (
      [href] =&gt; /api/1.0/widget/12345
    )
  )

  [count] =&gt; 1
  [_embedded] =&gt; Array (
    [0] =&gt; Array (
      [id] =&gt; 12345
      [type] =&gt; widget
      [path] =&gt; /node/157601
    )
  )
  [String] =&gt; 'This is a string that I'm adding to the widget response'
)


Read more Drupal: Alter API response with Services API, where is this example was taken from.