jodd-json/src/main/java/jodd/json/impl/KeyValueJsonSerializer.java
protected int serializeKeyValue(final JsonContext jsonContext, final Path currentPath, final Object key, final Object value, int count) {
		if ((value == null) && jsonContext.isExcludeNulls()) {
			return count;
		}

		if (key != null) {
			currentPath.push(key.toString());
		} else {
			currentPath.push(StringPool.NULL);
		}

		// check if we should include the field

		boolean include = true;

		if (value != null) {

			// + all collections are not serialized by default

			include = jsonContext.matchIgnoredPropertyTypes(value.getClass(), false, include);

			// + path queries: excludes/includes

			include = jsonContext.matchPathToQueries(include);
		}

		// done

		if (!include) {
			currentPath.pop();
			return count;
		}

		if (key == null) {
			jsonContext.pushName(null, count > 0);
		} else {
			jsonContext.pushName(key.toString(), count > 0);
		}

		jsonContext.serialize(value);

		if (jsonContext.isNamePopped()) {
			count++;
		}

		currentPath.pop();
		return count;
	}
protected int serializeKeyValue(final JsonContext jsonContext, final Path currentPath, final Object key, final Object value, int count) {
		if ((value == null) && jsonContext.isExcludeNulls()) {
			return count;
		}

		if (key != null) {
			currentPath.push(key.toString());
		} else {
			currentPath.push(StringPool.NULL);
		}

		// check if we should include the field

		boolean include = true;

		if (value != null) {

			// + all collections are not serialized by default

			include = jsonContext.matchIgnoredPropertyTypes(value.getClass(), false, include);

			// + path queries: excludes/includes

			include = jsonContext.matchPathToQueries(include);
		}

		// done

		if (!include) {
			currentPath.pop();
			return count;
		}

		if (key == null) {
			jsonContext.pushName(null, count > 0);
		} else {
			jsonContext.pushName(key.toString(), count > 0);
		}

		jsonContext.serialize(value);

		if (jsonContext.isNamePopped()) {
			count++;
		}

		currentPath.pop();
		return count;
	}
protected int serializeKeyValue ( final JsonContext jsonContext , final Path currentPath , final Object key , final Object value , int count ) { if ( ( value == null ) && jsonContext . isExcludeNulls ( ) ) { return count ; } if ( key != null ) { currentPath . push ( key . toString ( ) ) ; } else { currentPath . push ( StringPool . NULL ) ; } // check if we should include the field boolean include = true ; if ( value != null ) { // + all collections are not serialized by default include = jsonContext . matchIgnoredPropertyTypes ( value . getClass ( ) , false , include ) ; // + path queries: excludes/includes include = jsonContext . matchPathToQueries ( include ) ; } // done if ( ! include ) { currentPath . pop ( ) ; return count ; } if ( key == null ) { jsonContext . pushName ( null , count > 0 ) ; } else { jsonContext . pushName ( key . toString ( ) , count > 0 ) ; } jsonContext . serialize ( value ) ; if ( jsonContext . isNamePopped ( ) ) { count ++ ; } currentPath . pop ( ) ; return count ; }
Serializes key and a value.
Serializes key and a value .