Fails if the selected JSON is not a String or is not present.
772119
public ResultMatcher isString() {
        return new AbstractResultMatcher(path, configuration) {
            public void doMatch(Object actual) {
                isString(actual);
            }
        };
    }
306507
private static Optional<ICondition> asContainsAny( JsonObject json)
    {
    return
      json.containsKey( HAS_ANY_KEY)
      ? Optional.of( new ContainsAny( toIdentifiers( json.getJsonArray( HAS_ANY_KEY))))
      : Optional.empty();
    }
866322
function isJSON(value, visited) {
    // Adding value to array of visited values.
    (visited || (visited = [])).push(value);
            // If `value` is an atom return `true` cause it"s valid JSON.
    return  isPrimitive(value) ||
            // If `value` is an array of JSON values that has not been visited
            // yet.
            (isArray(value) &&  value.every(function(element) {
                                  return isJSON(element, visited);
                                })) ||
            // If `value` is a plain object containing properties with a JSON
            // values it"s a valid JSON.
            (isFlat(value) && Object.keys(value).every(function(key) {
                var $ = Object.getOwnPropertyDescriptor(value, key);
                // Check every proprety of a plain object to verify that
                // it"s neither getter nor setter, but a JSON value, that
                // has not been visited yet.
                return  ((!isObject($.value) || !~visited.indexOf($.value)) &&
                        !("get" in $) && !("set" in $) &&
                        isJSON($.value, visited));
            }));
}
818946
private static Optional<ICondition> asContainsNone( JsonObject json)
    {
    return
      json.containsKey( HAS_NONE_KEY)
      ? Optional.of( new Not( new ContainsAny( toIdentifiers( json.getJsonArray( HAS_NONE_KEY)))))
      : Optional.empty();
    }
985609
private static Optional<ICondition> asNotMoreThan( JsonObject json)
    {
    return
      Optional.of( json)
      .filter( j -> j.containsKey( NOT_MORE_THAN_KEY))
      .map( j -> j.getJsonObject( NOT_MORE_THAN_KEY))
      .map( a -> new AssertNotMore( a.getString( PROPERTY_KEY), a.getInt( MAX_KEY)));
    }
351852
def is_json_compat(value):
    

    try:
        value = json.loads(value)
    except ValueError as e:
        raise ValueError('JSON decoding error: ' + str(e))
    except TypeError:
        # Check that the value can be serialized back into json.
        try:
            json.dumps(value)
        except TypeError as e:
            raise ValueError(
                'must be a JSON serializable object: ' + str(e))

    if not isinstance(value, dict):
        raise ValueError(
            'must be specified as a JSON serializable dict or a '
            'JSON deserializable string'
        )

    return True
475109
public static boolean isValidJsonStrict(String s) {
		try {
			new JSONParser(MODE_RFC4627).parse(s, FakeMapper.DEFAULT);
			return true;
		} catch (ParseException e) {
			return false;
		}
	}
1253745
def is_json(self, headers):
        """"""
        ret = False
        ct = headers.get("content-type", "").lower()
        if ct:
            ret = ct.lower().rfind("json") >= 0
        return ret
1224863
void toJSONString(final Map<ReferenceEqualityKey<JSONReference>, CharSequence> jsonReferenceToId,
            final boolean includeNullValuedFields, final int depth, final int indentWidth,
            final StringBuilder buf) {
        final boolean prettyPrint = indentWidth > 0;
        final int n = items.size();
        int numDisplayedFields;
        if (includeNullValuedFields) {
            numDisplayedFields = n;
        } else {
            numDisplayedFields = 0;
            for (final Entry<String, Object> item : items) {
                if (item.getValue() != null) {
                    numDisplayedFields++;
                }
            }
        }
        if (objectId == null && numDisplayedFields == 0) {
            buf.append("{}");
        } else {
            buf.append(prettyPrint ? "{\n" : "{");
            if (objectId != null) {
                // id will be non-null if this object does not have an @Id field, but was referenced by
                // another object (need to include ID_TAG)
                if (prettyPrint) {
                    JSONUtils.indent(depth + 1, indentWidth, buf);
                }
                buf.append('"');
                buf.append(JSONUtils.ID_KEY);
                buf.append(prettyPrint ? "\": " : "\":");
                JSONSerializer.jsonValToJSONString(objectId, jsonReferenceToId, includeNullValuedFields, depth + 1,
                        indentWidth, buf);
                if (numDisplayedFields > 0) {
                    buf.append(',');
                }
                if (prettyPrint) {
                    buf.append('\n');
                }
            }
            for (int i = 0, j = 0; i < n; i++) {
                final Entry<String, Object> item = items.get(i);
                final Object val = item.getValue();
                if (val != null || includeNullValuedFields) {
                    final String key = item.getKey();
                    if (key == null) {
                        // Keys must be quoted, so the unquoted null value cannot be a key
                        // (Should not happen -- JSONParser.parseJSONObject checks for null keys)
                        throw new IllegalArgumentException("Cannot serialize JSON object with null key");
                    }
                    if (prettyPrint) {
                        JSONUtils.indent(depth + 1, indentWidth, buf);
                    }
                    buf.append('"');
                    JSONUtils.escapeJSONString(key, buf);
                    buf.append(prettyPrint ? "\": " : "\":");
                    JSONSerializer.jsonValToJSONString(val, jsonReferenceToId, includeNullValuedFields, depth + 1,
                            indentWidth, buf);
                    if (++j < numDisplayedFields) {
                        buf.append(',');
                    }
                    if (prettyPrint) {
                        buf.append('\n');
                    }
                }
            }
            if (prettyPrint) {
                JSONUtils.indent(depth, indentWidth, buf);
            }
            buf.append('}');
        }
    }
699534
private static Boolean getJsonValueAsBoolean(JsonValue value) {
        if (value != null) {
            if (value.getValueType() == ValueType.TRUE) {
                return true;
            } else if (value.getValueType() == ValueType.FALSE) {
                return false;
            }
        }
        return null;
    }
1291438
private static ICondition asValidCondition( JsonObject json)
    {
    try
      {
      return asCondition( json);
      }
    catch( SystemInputException e)
      {
      throw new SystemInputException( "Invalid condition", e);
      }
    }
706745
public static boolean isValidJsonValue( Object value ) {
      if( JSONNull.getInstance()
            .equals( value ) || value instanceof JSON || value instanceof Boolean
            || value instanceof Byte || value instanceof Short
            || value instanceof Integer || value instanceof Long || value instanceof Double
            || value instanceof BigInteger || value instanceof BigDecimal
            || value instanceof JSONFunction || value instanceof JSONString
            || value instanceof String ){
         return true;
      }
      return false;
   }
698248
private static Optional<ICondition> asAnyOf( JsonObject json)
    {
    return
      json.containsKey( ANY_OF_KEY)
      ? Optional.of( new AnyOf( toConditions( json.getJsonArray( ANY_OF_KEY))))
      : Optional.empty();
    }
499563
public static function isJson (string $string) : bool
    {
        if (is_numeric($string) || $string === 'true' || $string === 'false' || $string === 'null' || empty($string)) :
            return false;
        endif;

        // try to decode string
        json_decode($string);

        // check if error occured
        return json_last_error() === JSON_ERROR_NONE;
    }
1120973
public static boolean isJsonRequest(ServletRequest request) {

        HttpServletRequest sr = (HttpServletRequest)request;
        return (sr.getQueryString() != null) && (sr.getQueryString().contains("__json=true"));
    }
815655
def is_json(self):
        
        mt = self.mimetype
        return (
            mt == "application/json"
            or mt.startswith("application/")
            and mt.endswith("+json")
        )
832059
def __is_json_error(self, status, headers):
    
    content_header = headers.get('content-type', '')
    content_type, unused_params = cgi.parse_header(content_header)
    return (status.startswith('400') and
            content_type.lower() in _ALL_JSON_CONTENT_TYPES)