This commit is contained in:
Looly
2024-09-27 14:11:15 +08:00
parent 1c18ccf660
commit 499c3cf4df
13 changed files with 326 additions and 187 deletions

View File

@@ -17,7 +17,6 @@
package org.dromara.hutool.json;
import org.dromara.hutool.core.text.StrUtil;
import org.dromara.hutool.json.serializer.JSONMapper;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
@@ -27,11 +26,11 @@ public class IssueI9DX5HTest {
@Test
void xmlToJSONTest() {
final String xml = "<GoodMsg>你好</GoodMsg>";
final JSONMapper mapper = JSONMapper.of(JSONConfig.of(), entry -> {
final JSONFactory factory = JSONFactory.of(JSONConfig.of(), entry -> {
entry.setKey(StrUtil.toUnderlineCase((CharSequence) entry.getKey()));
return true;
});
final JSONObject jsonObject = (JSONObject) mapper.map(xml);
final JSONObject jsonObject = (JSONObject) factory.parse(xml);
Assertions.assertEquals("{\"good_msg\":\"你好\"}", jsonObject.toString());
}