// Path: json-unit-core/src/main/java/net/javacrumbs/jsonunit/core/internal/GenericNodeBuilder.java
// static abstract class NodeSkeleton extends AbstractNode {
//     @Override
//     public Node element(int index) {
//         return MISSING_NODE;
//     }
// 
//     @Override
//     public Iterator<KeyValue> fields() {
//         throw new UnsupportedOperationException();
//     }
// 
//     @Override
//     public Node get(String key) {
//         return MISSING_NODE;
//     }
// 
//     @Override
//     public boolean isMissingNode() {
//         return false;
//     }
// 
//     @Override
//     public boolean isNull() {
//         return false;
//     }
// 
//     @Override
//     public Iterator<Node> arrayElements() {
//         throw new UnsupportedOperationException();
//     }
// 
//     @Override
//     public int size() {
//         throw new UnsupportedOperationException();
//     }
// 
//     @Override
//     public String asText() {
//         throw new UnsupportedOperationException();
//     }
// 
//     @Override
//     public BigDecimal decimalValue() {
//         throw new UnsupportedOperationException();
//     }
// 
//     @Override
//     public Boolean asBoolean() {
//         throw new UnsupportedOperationException();
//     }
// }
// 
// Path: json-unit-core/src/main/java/net/javacrumbs/jsonunit/core/internal/Utils.java
// static void closeQuietly(final Reader resourceReader) {
//     if (resourceReader != null) {
//         try {
//             resourceReader.close();
//         } catch (IOException ignored) {
//         }
//     }
// }


import net.javacrumbs.jsonunit.core.internal.GenericNodeBuilder.NodeSkeleton;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONTokener;
import java.io.Reader;
import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
import static net.javacrumbs.jsonunit.core.internal.Utils.closeQuietly;
/**
 * Copyright 2009-2019 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package net.javacrumbs.jsonunit.core.internal;




/**
 * Deserializes node using org.json.JSONObject
 */
class JsonOrgNodeFactory extends AbstractNodeFactory {

    @Override
    protected Node doConvertValue(Object source) {
        return newNode(source);
    }

    @Override
    protected Node nullNode() {
        return newNode(null);
    }

    @Override
    protected Node readValue(Reader value, String label, boolean lenient) {
        try {
            return newNode(new JSONTokener(value).nextValue());
        } catch (JSONException e) {
            throw newParseException(label, value, e);
        } finally {
// Path: json-unit-core/src/main/java/net/javacrumbs/jsonunit/core/internal/GenericNodeBuilder.java
// static abstract class NodeSkeleton extends AbstractNode {
//     @Override
//     public Node element(int index) {
//         return MISSING_NODE;
//     }
// 
//     @Override
//     public Iterator<KeyValue> fields() {
//         throw new UnsupportedOperationException();
//     }
// 
//     @Override
//     public Node get(String key) {
//         return MISSING_NODE;
//     }
// 
//     @Override
//     public boolean isMissingNode() {
//         return false;
//     }
// 
//     @Override
//     public boolean isNull() {
//         return false;
//     }
// 
//     @Override
//     public Iterator<Node> arrayElements() {
//         throw new UnsupportedOperationException();
//     }
// 
//     @Override
//     public int size() {
//         throw new UnsupportedOperationException();
//     }
// 
//     @Override
//     public String asText() {
//         throw new UnsupportedOperationException();
//     }
// 
//     @Override
//     public BigDecimal decimalValue() {
//         throw new UnsupportedOperationException();
//     }
// 
//     @Override
//     public Boolean asBoolean() {
//         throw new UnsupportedOperationException();
//     }
// }
// 
// Path: json-unit-core/src/main/java/net/javacrumbs/jsonunit/core/internal/Utils.java
// static void closeQuietly(final Reader resourceReader) {
//     if (resourceReader != null) {
//         try {
//             resourceReader.close();
//         } catch (IOException ignored) {
//         }
//     }
// }


// Path: json-unit-core/src/main/java/net/javacrumbs/jsonunit/core/internal/JsonOrgNodeFactory.java
import net.javacrumbs.jsonunit.core.internal.GenericNodeBuilder.NodeSkeleton;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONTokener;
import java.io.Reader;
import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
import static net.javacrumbs.jsonunit.core.internal.Utils.closeQuietly;

/**
 * Copyright 2009-2019 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package net.javacrumbs.jsonunit.core.internal;




/**
 * Deserializes node using org.json.JSONObject
 */
class JsonOrgNodeFactory extends AbstractNodeFactory {

    @Override
    protected Node doConvertValue(Object source) {
        return newNode(source);
    }

    @Override
    protected Node nullNode() {
        return newNode(null);
    }

    @Override
    protected Node readValue(Reader value, String label, boolean lenient) {
        try {
            return newNode(new JSONTokener(value).nextValue());
        } catch (JSONException e) {
            throw newParseException(label, value, e);
        } finally {
            closeQuietly(value);