public static Object convert(YamlNode yamlNode) {
        if (yamlNode == null) {
            return JSONObject.NULL;
        }
        if (yamlNode instanceof YamlMapping yamlMapping) {
            JSONObject resultObject = new JSONObject();
            for (YamlNameNodePair pair : yamlMapping.childrenPairs()) {
                resultObject.put(pair.nodeName(), convert(pair.childNode()));
            }
            return resultObject;
        } else if (yamlNode instanceof YamlSequence yamlSequence) {
            JSONArray resultArray = new JSONArray();
            for (YamlNode child : yamlSequence.children()) {
                resultArray.put(convert(child));
            }
            return resultArray;
        } else if (yamlNode instanceof YamlScalar scalar) {
            return scalar.nodeValue();
        }
        throw new IllegalArgumentException("Unknown type " + yamlNode.getClass().getName());
    }
@Test
    public void emptyObject() {
        YamlMapping root = (YamlMapping) YamlLoader.load(
                getClass().getResourceAsStream("/com/hazelcast/config/empty-object.yaml"));
        JSONObject actual = (JSONObject) YamlToJsonConverter.convert(root);
        assertEquals(JSONObject.NULL, actual.getJSONObject("hazelcast").getJSONObject("network").get("memcache-protocol"));
    }