web123456

Java implements yaml to json method

public static JSONObject toJSONObject() { //Initialize the Yaml parser Yaml yaml = new Yaml(); File file = new File(""); //Read in file Object result= yaml.load(new FileInputStream(file)); return JSON.parseObject(JSON.toJSONString(result)); } public static JSONObject toJSONObject(String yamlContent) { Yaml yaml = new Yaml(); Object result = yaml.load(yamlContent); return JSON.parseObject(JSON.toJSONString(result)); }