import json


def _ParseJsonKeys(dictionary):
  """Replaces values with json strings with objects parsed from them.

  Certain nested json objects are returned as strings. We parse them to access
  their properties. Note this method is not recursive and only parses objects
  in the topmost level, i.e. only string values in the given dictionary and
  not in nested dictionaries it might contain.

  Args:
    dictionary: A dictionary with the original data.

  Returns:
    A copy of the original dictionary with appropriate replacements.
  """
  result = dictionary.copy()

  for key in result:
    if key.endswith('_json'):
      result[key.replace('_json', '')] = json.loads(result[key])
      result.pop(key)
  return result