// Path: src/main/java/pl/jalokim/propertiestojson/resolvers/primitives/utils/JsonObjectHelper.java
// public final class JsonObjectHelper {
// 
//     private static final PrimitiveJsonTypesResolver PRIMITIVE_JSON_TYPES_RESOLVER;
//     private static final JsonParser JSON_PARSER = new JsonParser();
//     private static final Gson GSON = new Gson();
// 
//     static {
//         List<ObjectToJsonTypeConverter<?>> toJsonResolvers = new ArrayList<>();
//         toJsonResolvers.add(new NumberToJsonTypeConverter());
//         toJsonResolvers.add(new BooleanToJsonTypeConverter());
//         toJsonResolvers.add(STRING_TO_JSON_RESOLVER);
// 
//         List<TextToConcreteObjectResolver<?>> toObjectsResolvers = new ArrayList<>();
//         toObjectsResolvers.add(new TextToNumberResolver());
//         toObjectsResolvers.add(new TextToBooleanResolver());
//         toObjectsResolvers.add(TO_STRING_RESOLVER);
//         PRIMITIVE_JSON_TYPES_RESOLVER = new PrimitiveJsonTypesResolver(toObjectsResolvers, toJsonResolvers, false, NULL_TO_JSON_RESOLVER);
//     }
// 
//     private JsonObjectHelper() {
//     }
// 
//     public static String toJson(Object object) {
//         return GSON.toJson(object);
//     }
// 
//     public static JsonElement toJsonElement(String json) {
//         return JSON_PARSER.parse(json);
//     }
// 
//     public static ObjectJsonType createObjectJsonType(JsonElement parsedJson, String propertyKey) {
//         ObjectJsonType objectJsonType = new ObjectJsonType();
//         JsonObject asJsonObject = parsedJson.getAsJsonObject();
//         for (Map.Entry<String, JsonElement> entry : asJsonObject.entrySet()) {
//             JsonElement someField = entry.getValue();
//             AbstractJsonType valueOfNextField = convertToAbstractJsonType(someField, propertyKey);
//             objectJsonType.addField(entry.getKey(), valueOfNextField, null);
//         }
//         return objectJsonType;
//     }
// 
//     public static AbstractJsonType convertToAbstractJsonType(JsonElement someField, String propertyKey) {
//         AbstractJsonType valueOfNextField = null;
//         if (someField.isJsonNull()) {
//             valueOfNextField = NULL_OBJECT;
//         }
//         if (someField.isJsonObject()) {
//             valueOfNextField = createObjectJsonType(someField, propertyKey);
//         }
//         if (someField.isJsonArray()) {
//             valueOfNextField = createArrayJsonType(someField, propertyKey);
//         }
//         if (someField.isJsonPrimitive()) {
//             JsonPrimitive jsonPrimitive = someField.getAsJsonPrimitive();
//             if (jsonPrimitive.isString()) {
//                 valueOfNextField = PRIMITIVE_JSON_TYPES_RESOLVER.resolvePrimitiveTypeAndReturn(jsonPrimitive.getAsString(), propertyKey);
//             } else if (jsonPrimitive.isNumber()) {
//                 String numberAsText = jsonPrimitive.getAsNumber().toString();
//                 valueOfNextField = PRIMITIVE_JSON_TYPES_RESOLVER.resolvePrimitiveTypeAndReturn(convertToNumber(numberAsText), propertyKey);
//             } else if (jsonPrimitive.isBoolean()) {
//                 valueOfNextField = PRIMITIVE_JSON_TYPES_RESOLVER.resolvePrimitiveTypeAndReturn(jsonPrimitive.getAsBoolean(), propertyKey);
//             }
//         }
//         return valueOfNextField;
//     }
// 
//     public static ArrayJsonType createArrayJsonType(JsonElement parsedJson, String propertyKey) {
//         ArrayJsonType arrayJsonType = new ArrayJsonType();
//         JsonArray asJsonArray = parsedJson.getAsJsonArray();
//         int index = 0;
//         for (JsonElement element : asJsonArray) {
//             arrayJsonType.addElement(index, convertToAbstractJsonType(element, propertyKey), null);
//             index++;
//         }
//         return arrayJsonType;
//     }
// 
//     public static boolean isValidJsonObjectOrArray(String propertyValue) {
//         if (hasJsonObjectSignature(propertyValue) || hasJsonArraySignature(propertyValue)) {
//             JsonParser jp = new JsonParser();
//             try {
//                 jp.parse(propertyValue);
//                 return true;
//             } catch (Exception ex) {
//                 return false;
//             }
//         }
//         return false;
//     }
// 
//     public static boolean hasJsonArraySignature(String propertyValue) {
//         return hasJsonSignature(propertyValue.trim(), ARRAY_START_SIGN, ARRAY_END_SIGN);
//     }
// 
//     public static boolean hasJsonObjectSignature(String propertyValue) {
//         return hasJsonSignature(propertyValue.trim(), JSON_OBJECT_START, JSON_OBJECT_END);
//     }
// 
//     private static boolean hasJsonSignature(String propertyValue, String startSign, String endSign) {
//         return firsLetter(propertyValue).contains(startSign) && lastLetter(propertyValue).contains(endSign);
//     }
// 
//     private static String firsLetter(String text) {
//         return text.substring(0, 1);
//     }
// 
//     private static String lastLetter(String text) {
//         return text.substring(text.length() - 1);
//     }
// }


import com.google.gson.JsonObject;
import pl.jalokim.propertiestojson.resolvers.primitives.utils.JsonObjectHelper;
package pl.jalokim.propertiestojson.util;


public class JsonCheckerUtil {

    public static boolean leafOfPathIsNotPresent(String jsonPath, String jsonAsText) {
        JsonObject jsonObject = JsonObjectHelper.toJsonElement(jsonAsText).getAsJsonObject();
        String[] jsonPaths = jsonPath.split("\\.");

        for (int i = 0; i < jsonPath.length(); i++) {
            if (i == jsonPaths.length - 1) {
                return !jsonObject.has(jsonPaths[i]);
            }
            jsonObject = jsonObject.getAsJsonObject(jsonPaths[i]);
        }
        throw new IllegalArgumentException("cannot find path: " + jsonPath + " in json" + jsonAsText);
    }

    public static boolean leafOfPathHasNullValue(String jsonPath, String jsonAsText) {
// Path: src/main/java/pl/jalokim/propertiestojson/resolvers/primitives/utils/JsonObjectHelper.java
// public final class JsonObjectHelper {
// 
//     private static final PrimitiveJsonTypesResolver PRIMITIVE_JSON_TYPES_RESOLVER;
//     private static final JsonParser JSON_PARSER = new JsonParser();
//     private static final Gson GSON = new Gson();
// 
//     static {
//         List<ObjectToJsonTypeConverter<?>> toJsonResolvers = new ArrayList<>();
//         toJsonResolvers.add(new NumberToJsonTypeConverter());
//         toJsonResolvers.add(new BooleanToJsonTypeConverter());
//         toJsonResolvers.add(STRING_TO_JSON_RESOLVER);
// 
//         List<TextToConcreteObjectResolver<?>> toObjectsResolvers = new ArrayList<>();
//         toObjectsResolvers.add(new TextToNumberResolver());
//         toObjectsResolvers.add(new TextToBooleanResolver());
//         toObjectsResolvers.add(TO_STRING_RESOLVER);
//         PRIMITIVE_JSON_TYPES_RESOLVER = new PrimitiveJsonTypesResolver(toObjectsResolvers, toJsonResolvers, false, NULL_TO_JSON_RESOLVER);
//     }
// 
//     private JsonObjectHelper() {
//     }
// 
//     public static String toJson(Object object) {
//         return GSON.toJson(object);
//     }
// 
//     public static JsonElement toJsonElement(String json) {
//         return JSON_PARSER.parse(json);
//     }
// 
//     public static ObjectJsonType createObjectJsonType(JsonElement parsedJson, String propertyKey) {
//         ObjectJsonType objectJsonType = new ObjectJsonType();
//         JsonObject asJsonObject = parsedJson.getAsJsonObject();
//         for (Map.Entry<String, JsonElement> entry : asJsonObject.entrySet()) {
//             JsonElement someField = entry.getValue();
//             AbstractJsonType valueOfNextField = convertToAbstractJsonType(someField, propertyKey);
//             objectJsonType.addField(entry.getKey(), valueOfNextField, null);
//         }
//         return objectJsonType;
//     }
// 
//     public static AbstractJsonType convertToAbstractJsonType(JsonElement someField, String propertyKey) {
//         AbstractJsonType valueOfNextField = null;
//         if (someField.isJsonNull()) {
//             valueOfNextField = NULL_OBJECT;
//         }
//         if (someField.isJsonObject()) {
//             valueOfNextField = createObjectJsonType(someField, propertyKey);
//         }
//         if (someField.isJsonArray()) {
//             valueOfNextField = createArrayJsonType(someField, propertyKey);
//         }
//         if (someField.isJsonPrimitive()) {
//             JsonPrimitive jsonPrimitive = someField.getAsJsonPrimitive();
//             if (jsonPrimitive.isString()) {
//                 valueOfNextField = PRIMITIVE_JSON_TYPES_RESOLVER.resolvePrimitiveTypeAndReturn(jsonPrimitive.getAsString(), propertyKey);
//             } else if (jsonPrimitive.isNumber()) {
//                 String numberAsText = jsonPrimitive.getAsNumber().toString();
//                 valueOfNextField = PRIMITIVE_JSON_TYPES_RESOLVER.resolvePrimitiveTypeAndReturn(convertToNumber(numberAsText), propertyKey);
//             } else if (jsonPrimitive.isBoolean()) {
//                 valueOfNextField = PRIMITIVE_JSON_TYPES_RESOLVER.resolvePrimitiveTypeAndReturn(jsonPrimitive.getAsBoolean(), propertyKey);
//             }
//         }
//         return valueOfNextField;
//     }
// 
//     public static ArrayJsonType createArrayJsonType(JsonElement parsedJson, String propertyKey) {
//         ArrayJsonType arrayJsonType = new ArrayJsonType();
//         JsonArray asJsonArray = parsedJson.getAsJsonArray();
//         int index = 0;
//         for (JsonElement element : asJsonArray) {
//             arrayJsonType.addElement(index, convertToAbstractJsonType(element, propertyKey), null);
//             index++;
//         }
//         return arrayJsonType;
//     }
// 
//     public static boolean isValidJsonObjectOrArray(String propertyValue) {
//         if (hasJsonObjectSignature(propertyValue) || hasJsonArraySignature(propertyValue)) {
//             JsonParser jp = new JsonParser();
//             try {
//                 jp.parse(propertyValue);
//                 return true;
//             } catch (Exception ex) {
//                 return false;
//             }
//         }
//         return false;
//     }
// 
//     public static boolean hasJsonArraySignature(String propertyValue) {
//         return hasJsonSignature(propertyValue.trim(), ARRAY_START_SIGN, ARRAY_END_SIGN);
//     }
// 
//     public static boolean hasJsonObjectSignature(String propertyValue) {
//         return hasJsonSignature(propertyValue.trim(), JSON_OBJECT_START, JSON_OBJECT_END);
//     }
// 
//     private static boolean hasJsonSignature(String propertyValue, String startSign, String endSign) {
//         return firsLetter(propertyValue).contains(startSign) && lastLetter(propertyValue).contains(endSign);
//     }
// 
//     private static String firsLetter(String text) {
//         return text.substring(0, 1);
//     }
// 
//     private static String lastLetter(String text) {
//         return text.substring(text.length() - 1);
//     }
// }


// Path: src/test/java/pl/jalokim/propertiestojson/util/JsonCheckerUtil.java
import com.google.gson.JsonObject;
import pl.jalokim.propertiestojson.resolvers.primitives.utils.JsonObjectHelper;

package pl.jalokim.propertiestojson.util;


public class JsonCheckerUtil {

    public static boolean leafOfPathIsNotPresent(String jsonPath, String jsonAsText) {
        JsonObject jsonObject = JsonObjectHelper.toJsonElement(jsonAsText).getAsJsonObject();
        String[] jsonPaths = jsonPath.split("\\.");

        for (int i = 0; i < jsonPath.length(); i++) {
            if (i == jsonPaths.length - 1) {
                return !jsonObject.has(jsonPaths[i]);
            }
            jsonObject = jsonObject.getAsJsonObject(jsonPaths[i]);
        }
        throw new IllegalArgumentException("cannot find path: " + jsonPath + " in json" + jsonAsText);
    }

    public static boolean leafOfPathHasNullValue(String jsonPath, String jsonAsText) {
        JsonObject jsonObject = JsonObjectHelper.toJsonElement(jsonAsText).getAsJsonObject();