import json
import collections


def ParseCheckSpecs(json_spec):
  """Parses the JSON string into the Checks parameters.

  Args:
    json_spec: the JSON string that contains the parameters of the check.

  Returns:
    The parameters of the Check, with properly instantiated set if
    there is one.
  """
  specs = json.loads(json_spec, object_pairs_hook=collections.OrderedDict)
  for category in ['warning_ranges', 'normal_ranges']:
    if category not in specs:
      continue

    parameters = []
    current_range = specs[category]
    if 'ranges' in current_range:
      parameters += current_range['ranges']
    if 'values' in current_range:
      parameters.append(set(current_range['values']))

    specs[category] = parameters

  return specs