This commit is contained in:
Looly
2024-04-11 23:27:56 +08:00
parent a066afd4d4
commit 26dcf5fd3d
5 changed files with 99 additions and 25 deletions

View File

@@ -0,0 +1,20 @@
package org.dromara.hutool.json;
import org.dromara.hutool.core.text.StrUtil;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
public class IssueI9DX5HTest {
@SuppressWarnings("MismatchedQueryAndUpdateOfCollection")
@Test
void xmlToJSONTest() {
final String xml = "<GoodMsg>你好</GoodMsg>";
final JSONObject jsonObject = new JSONObject(xml, JSONConfig.of(), entry -> {
entry.setKey(StrUtil.toUnderlineCase(entry.getKey()));
return true;
});
Assertions.assertEquals("{\"good_msg\":\"你好\"}", jsonObject.toString());
}
}