All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.arextest.diff.utils.JacksonHelperUtil Maven / Gradle / Ivy

There is a newer version: 0.2.15
Show newest version
package com.arextest.diff.utils;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by rchen9 on 2023/2/16.
 */
public class JacksonHelperUtil {

  public static ObjectMapper objectMapper = new ObjectMapper();

  public static List getNames(ObjectNode objectNode) {
    List result = new ArrayList<>(objectNode.size());
    objectNode.fieldNames().forEachRemaining(result::add);
    return result;
  }

  public static ObjectNode getObjectNode() {
    return objectMapper.createObjectNode();
  }

  public static ArrayNode getArrayNode() {
    return objectMapper.createArrayNode();
  }

  public static boolean isObjectNode(Object object) {
    return object instanceof ObjectNode;
  }

  public static boolean isArrayNode(Object object) {
    return object instanceof ArrayNode;
  }


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy