From c288e157a4e51199f20134c2ef9da6f780487c5f Mon Sep 17 00:00:00 2001 From: "Jonguk. Lim" Date: Wed, 23 Nov 2022 04:20:00 +0900 Subject: [PATCH] feat: xml parse --- pom.xml | 9 +++++++++ .../xit/framework/support/util/JsonUtil.java | 18 ++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/pom.xml b/pom.xml index 96b37a99..ebe91223 100644 --- a/pom.xml +++ b/pom.xml @@ -594,6 +594,15 @@ + + + org.json + json + 20220924 + + + + org.springframework.restdocs diff --git a/src/main/java/kr/xit/framework/support/util/JsonUtil.java b/src/main/java/kr/xit/framework/support/util/JsonUtil.java index d8bad0d0..9fb2e018 100644 --- a/src/main/java/kr/xit/framework/support/util/JsonUtil.java +++ b/src/main/java/kr/xit/framework/support/util/JsonUtil.java @@ -4,6 +4,9 @@ import java.io.IOException; import java.util.List; import java.util.Map; +import org.json.JSONObject; +import org.json.XML; + import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.type.TypeReference; @@ -158,5 +161,20 @@ public class JsonUtil { sb.insert(0, '\n'); return sb.toString(); } + + public static void main(String[] args) { + String xmlStr = + "\n" + + "\n" + + "Tove\n" + + "Jani\n" + + "Reminder\n" + + "Don't forget me this weekend!\n" + + ""; + + JSONObject json = XML.toJSONObject(xmlStr); + String jsonStr = json.toString(4); + System.out.println(jsonStr); + } }