code: def filter_fields_from_response(fields, response):
      """Format the response as a JSON string, using any filtering included in
      the request.
  
      :param fields:str the value of the `fields` parameter in the original
          request.
      :param response:dict a dictionary to be formatted as a JSON string.
      :return: the response formatted as a string.
      :rtype:str
      """
      if fields is None:
          return json.dumps(response)
      tmp = {}
      fields.replace(" ", "")
      for keys in field_match.findall(fields):
          if keys[2]:
              if keys[2] not in response:
                  continue
              tmp[keys[2]] = response[keys[2]]
          else:
              if keys[0] not in response:
                  continue
              childrens = response[keys[0]]
              if isinstance(childrens, list):
                  tmp_list = []
                  for children in childrens:
                      child = {}
                      for child_key in keys[1].split(","):
                          child[child_key] = children[child_key]
                      tmp_list.append(child)
                  tmp[keys[0]] = tmp_list
              elif isinstance(childrens, dict):
                  child = {}
                  for child_key in keys[1].split(","):
                      child[child_key] = children[child_key]
                  tmp[keys[0]] = child
      return json.dumps(tmp)
  
imports: import base64
  import error_response
  import hashlib
  import json
  import random
  import re
label_desc: Use image node_id 1 for calling a global function with example usage: filter_fields_from_response(fields, response) and returns: json, json