// Path: json-unit-core/src/main/java/net/javacrumbs/jsonunit/core/internal/ArrayUtils.java
// static List<Boolean> toBoolList(boolean[] source) {
//     List<Boolean> result = new ArrayList<>(source.length);
//     for (boolean value : source) {
//         result.add(value);
//     }
//     return result;
// }
// 
// Path: json-unit-core/src/main/java/net/javacrumbs/jsonunit/core/internal/ArrayUtils.java
// static List<Double> toDoubleList(double[] source) {
//     return Arrays.stream(source).boxed().collect(toList());
// }
// 
// Path: json-unit-core/src/main/java/net/javacrumbs/jsonunit/core/internal/ArrayUtils.java
// static List<Integer> toIntList(int[] source) {
//     return Arrays.stream(source).boxed().collect(toList());
// }


import org.apache.johnzon.core.JsonLongImpl;
import org.apache.johnzon.mapper.Mapper;
import org.apache.johnzon.mapper.MapperBuilder;
import javax.json.Json;
import javax.json.JsonArray;
import javax.json.JsonNumber;
import javax.json.JsonObject;
import javax.json.JsonReader;
import javax.json.JsonString;
import javax.json.JsonValue;
import javax.json.stream.JsonParsingException;
import java.io.Reader;
import java.math.BigDecimal;
import java.util.Iterator;
import java.util.Map;
import static java.util.Arrays.asList;
import static net.javacrumbs.jsonunit.core.internal.ArrayUtils.toBoolList;
import static net.javacrumbs.jsonunit.core.internal.ArrayUtils.toDoubleList;
import static net.javacrumbs.jsonunit.core.internal.ArrayUtils.toIntList;
/**
 * Copyright 2009-2019 the original author or authors.
 * <p>
 * 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
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * 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;




public class JohnzonNodeFactory extends AbstractNodeFactory {

    private final Mapper mapper = new MapperBuilder().build();

    @Override
    protected Node doConvertValue(Object source) {
        if (source instanceof JsonValue) {
            return newNode((JsonValue) source);
        } else if (source instanceof int[]) {
            // Johnzon can't convert arrays but it support lists
            return newNode(mapper.toStructure(toIntList((int[]) source)));
        } else if (source instanceof double[]) {
            // Johnzon can't convert arrays but it support lists
// Path: json-unit-core/src/main/java/net/javacrumbs/jsonunit/core/internal/ArrayUtils.java
// static List<Boolean> toBoolList(boolean[] source) {
//     List<Boolean> result = new ArrayList<>(source.length);
//     for (boolean value : source) {
//         result.add(value);
//     }
//     return result;
// }
// 
// Path: json-unit-core/src/main/java/net/javacrumbs/jsonunit/core/internal/ArrayUtils.java
// static List<Double> toDoubleList(double[] source) {
//     return Arrays.stream(source).boxed().collect(toList());
// }
// 
// Path: json-unit-core/src/main/java/net/javacrumbs/jsonunit/core/internal/ArrayUtils.java
// static List<Integer> toIntList(int[] source) {
//     return Arrays.stream(source).boxed().collect(toList());
// }


// Path: json-unit-core/src/main/java/net/javacrumbs/jsonunit/core/internal/JohnzonNodeFactory.java
import org.apache.johnzon.core.JsonLongImpl;
import org.apache.johnzon.mapper.Mapper;
import org.apache.johnzon.mapper.MapperBuilder;
import javax.json.Json;
import javax.json.JsonArray;
import javax.json.JsonNumber;
import javax.json.JsonObject;
import javax.json.JsonReader;
import javax.json.JsonString;
import javax.json.JsonValue;
import javax.json.stream.JsonParsingException;
import java.io.Reader;
import java.math.BigDecimal;
import java.util.Iterator;
import java.util.Map;
import static java.util.Arrays.asList;
import static net.javacrumbs.jsonunit.core.internal.ArrayUtils.toBoolList;
import static net.javacrumbs.jsonunit.core.internal.ArrayUtils.toDoubleList;
import static net.javacrumbs.jsonunit.core.internal.ArrayUtils.toIntList;

/**
 * Copyright 2009-2019 the original author or authors.
 * <p>
 * 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
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * 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;




public class JohnzonNodeFactory extends AbstractNodeFactory {

    private final Mapper mapper = new MapperBuilder().build();

    @Override
    protected Node doConvertValue(Object source) {
        if (source instanceof JsonValue) {
            return newNode((JsonValue) source);
        } else if (source instanceof int[]) {
            // Johnzon can't convert arrays but it support lists
            return newNode(mapper.toStructure(toIntList((int[]) source)));
        } else if (source instanceof double[]) {
            // Johnzon can't convert arrays but it support lists
            return newNode(mapper.toStructure(toDoubleList((double[]) source)));