Parses a JSON string.
 @param [String] json the JSON formatted string
 @return [Hash]
176416
def parse_json(json)
      hash = JSON.parse(json, :symbolize_names => true)

      # Convert hash[:created] and hash[:updated] to Time objects
      if hash[:created]
        hash.merge!({ :created => parse_iso_date_string(hash[:created]) })
      end

      if hash[:updated]
        hash.merge!({ :updated => parse_iso_date_string(hash[:updated]) })
      end

      hash
    end
1311074
def as_json(options = {})
      {}.tap do |result|
        result[:body] = @body unless @body.nil?
        result[:headers] = @headers unless @headers.nil?
        result[:status] = @status unless @status.nil?
      end
    end
1320796
def parse_hash(hash, convert_types = false)
      new_hash = {}
      hash.each do |k, v|
        if convert_types
          v = v.to_i if v && v.match(/^\d+$/)
          v = true if v == 'true'
          v = false if v == 'false'
          v = nil if v == 'nil'
        end
        if k =~ /\./
          sub_hash = new_hash
          split = k.split('.')
          split.each do |sub_key|
            if sub_key == split.last
              sub_hash[sub_key] = v
            else
              sub_hash[sub_key] ||= {}
              sub_hash = sub_hash[sub_key]
            end
          end
          new_hash[split.first] ||= {}
        else
          new_hash[k] = v
        end
      end
      new_hash
    end
1372446
def parse_params(request)
      json = request.body.read
      JSON.parse(json).symbolize_keys if json.is_a?(String) && !json.empty?
    end
1272127
def parse_json(response)
			json_response = JSON.parse(response)
			error = json_response['error']
			if !error.nil? then raise APIException.new(error) end
			return json_response
		end
621655
def as_json(options={})
      options = @options.merge(options)

      if options[:root]
        { options[:root].to_sym => serializable_hash }.merge(meta_hash).merge(data_hash)
      else
        serializable_hash
      end
    end
296451
def _is_json(string):
        
        try:
            if isinstance(string, bytes):
                json_str = json.loads(string.decode("utf-8"), object_pairs_hook=OrderedDict)
            elif isinstance(string, str):
                json_str = json.loads(string, object_pairs_hook=OrderedDict)
            else:
                raise TypeError("Expecting <class 'str'> or <class 'bytes'>, but {} was passed".format(type(string)))
            return json_str
        except ValueError:
            return False
828189
public void fromJson(String json) throws IOException, ParseException {
        JsonUtils.fromJson(this, json);
        this.json = json;
    }
311496
def as_json(_options = {})
      hash = {}
      instance_variables.each do |var|
        name = var[1..-1]

        if name =~ /^__/
          # if a variable starts with double underscore, strip one off
          name = name[1..-1]
        elsif name =~ /^_/
          # Hide variables that start with single underscore
          name = nil
        end

        hash[name] = instance_variable_get(var) if name
      end
      hash
    end
1132630
protected function parse_json( $json ) {

		$data = json_decode( $json, true );

		if ( ! is_array( $data ) ) {
			$data = array();
		}

		return $data;
	}
1166627
def create_hash(response)
      begin
        JSON.parse response
      rescue JSON::ParserError
        response
      rescue StandardError
        response
      end
    end
885726
def parse_json(raw_data):
    '''  '''

    orig_data = raw_data

    # ignore stuff like tcgetattr spewage or other warnings
    data = filter_leading_non_json_lines(raw_data)

    try:
        return json.loads(data)
    except:
        # not JSON, but try "Baby JSON" which allows many of our modules to not
        # require JSON and makes writing modules in bash much simpler
        results = {}
        try:
            tokens = shlex.split(data)
        except:
            print "failed to parse json: "+ data
            raise

        for t in tokens:
            if t.find("=") == -1:
                raise errors.AnsibleError("failed to parse: %s" % orig_data)
            (key,value) = t.split("=", 1)
            if key == 'changed' or 'failed':
                if value.lower() in [ 'true', '1' ]:
                    value = True
                elif value.lower() in [ 'false', '0' ]:
                    value = False
            if key == 'rc':
                value = int(value)
            results[key] = value
        if len(results.keys()) == 0:
            return { "failed" : True, "parsed" : False, "msg" : orig_data }
        return results
598786
def parse_json(raw_json):
        
        result = json.loads(raw_json)

        if 'results' in result:
            result = result['results']

        return result
884993
def parse_response(response)
      if response.headers['Content-Type'].include?('application/json')
        parse_json(response.body)
      else
        response.body
      end
    end
900711
def parsed_response(body)
      [JSON.parse(body), '']
    rescue JSON::ParserError
      ['', body.match(/message='([^']+)'/).captures.first]
    end
205125
def parse_json(filename):
    
    # Regular expression for comments
    comment_re = re.compile(
        '(^)?[^\S\n]*/(?:\*(.*?)\*/[^\S\n]*|/[^\n]*)($)?',
        re.DOTALL | re.MULTILINE
    )

    with open(filename) as f:
        content = ''.join(f.readlines())

        ## Looking for comments
        match = comment_re.search(content)
        while match:
            # single line comment
            content = content[:match.start()] + content[match.end():]
            match = comment_re.search(content)

        # Return json file
        return json.loads(content)
407016
def load_json(key)
      path = if yaml[key] =~ %r{^/} # root path given
               yaml[key]
             else # relative path
               dirname = File.dirname(options[:config])
               "#{dirname}/#{yaml[key]}"
             end
      if File.exist?(path)
        Mash.from_hash(JSON.parse(IO.read(path)))
      else
        puts "ERROR: #{key}.json config does not exist at: #{path}"
        exit 1
      end
    end