Returns the input if it is a JSON-permissible value; throws otherwise.
323875
static double checkDouble(double d) throws JSONException {
        if (Double.isInfinite(d) || Double.isNaN(d)) {
            throw new JSONException("Forbidden numeric value: " + d);
        }
        return d;
    }
862605
public function wantsJson(): bool
    {
        $acceptable = $this->serverRequest->getHeaderLine('Accept');

        return $acceptable !== null && Strings::contains($acceptable, ['/json', '+json']);
    }
951099
function serialize(input) {
    const value = JSON.stringify(input);
    return value === undefined
        ? reject(new Error(`Unsupported type ${type(input)}`))
        : resolve(value);
}
755536
public static boolean isValidJson(String s) {
		try {
			new JSONParser(DEFAULT_PERMISSIVE_MODE).parse(s, FakeMapper.DEFAULT);
			return true;
		} catch (ParseException e) {
			return false;
		}
	}
252903
@GwtIncompatible("Unnecessary")
  private boolean isOutputInJson() {
    return config.jsonStreamMode == JsonStreamMode.OUT
        || config.jsonStreamMode == JsonStreamMode.BOTH;
  }
809309
public void parse () throws JsonParseException
  {
    _readValue ();

    // Check for trailing whitespaces
    _skipSpaces ();

    final IJsonParsePosition aStartPos = m_aPos.getClone ();

    // Check for expected end of input
    final int c = _readChar ();
    if (c != EOI)
      throw _parseEx (aStartPos, "Invalid character " + _getPrintableChar (c) + " after JSON root object");
  }
175667
def json(value, pretty=True):
    
    if not _Duration:
        _late_import()
    return _json_encoder(value, pretty=pretty)
12503
def json_val(path, *, ignore_bad_path=False):
  """"""
  return lambda source: get_json_val(source, path, ignore_bad_path=ignore_bad_path)
740678
def serialize_json_string(self, value):
        

        # Check if the value might be a json string
        if not isinstance(value, six.string_types):
            return value

        # Make sure it starts with a brace
        if not value.startswith('{') or value.startswith('['):
            return value

        # Try to load the string
        try:
            return json.loads(value)
        except:
            return value
277518
private static SystemInputDef asSystemInputDef( JsonValue json)
    {
    try
      {
      SystemInputDef systemInput = null;
      if( json != null && json.getValueType() == OBJECT)
        {
        systemInput = SystemInputJson.asSystemInputDef( (JsonObject) json);
        }

      return systemInput;
      }
    catch( Exception e)
      {
      throw new ProjectException( "Error reading input definition", e);
      }
    }
1070049
public static boolean isValidJson(Reader in) throws IOException {
		try {
			new JSONParser(DEFAULT_PERMISSIVE_MODE).parse(in, FakeMapper.DEFAULT);
			return true;
		} catch (ParseException e) {
			return false;
		}
	}
152812
def handle_json(json_str)
      begin
        req  = JSON::parse(json_str)
        resp = handle(req)
      rescue JSON::ParserError => e
        resp = err_resp({ }, -32700, "Unable to parse JSON: #{e.message}")
      end
      
      # Note the `:ascii_only` usage here. Important.
      return JSON::generate(resp, { :ascii_only=>true })
    end
828796
function parseJson(name, type, value) {
    try {
        return typeof value  === 'string' ?
            JSON.parse(value) :
            value;
    } catch (e) {
        throwError(name, type, value);
    }
}
109794
function parseIfJson(val) {
    if (_.isString(val)) {
        val = val.trim();
        if (val.substring(0, 1) === '{' && val.substring(val.length - 1) === '}') {
            try {
                val = JSON.parse(val);
            }
            catch (ex) {
                /* eslint no-console:0 */
                console.log(ex);
            }
        }
    }
    return val;
}
1031166
def get_json_val(source, path, *, ignore_bad_path=False):
  """"""
  try:
    return JP.find(source, path)
  except JP.JSONPathError as ex:
    if ignore_bad_path:
      return None
    else:
      raise
572927
def _process_value(self, value, type):
        

        if not isinstance(value, six.string_types + (list,)):
            value = json.dumps(value)
        return value
1019464
def fromJSON(value):
        
        j = json.loads(value)
        v = GPBoolean()
        if "defaultValue" in j:
            v.value = j['defaultValue']
        else:
            v.value = j['value']
        if 'paramName' in j:
            v.paramName = j['paramName']
        elif 'name' in j:
            v.paramName = j['name']
        return v