Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

json相关工具包,如:json格式化、属性过滤等

Notifications You must be signed in to change notification settings

feiyu22/json-util

Open more actions menu
 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

json-util

这是一json相关的工具包,不包含序列化及反序列化实现,你可以使用fastjsonjackson等库,目前实现常用的工具有:

  • 格式化
        String json = "{\"name\":\"mi米\",\"age\":30,\"weight\":100.1,\"Children\":[\"a\",\"b\",\"c\"],\"address\":{ \"city\":\"GuangZhou\",\"pro\":\"GuangDong\"}}";

        String expect = "{\n" +
                "   \"name\": \"mi米\",\n" +
                "   \"age\": 30,\n" +
                "   \"weight\": 100.1,\n" +
                "   \"Children\": [\n" +
                "      \"a\",\n" +
                "      \"b\",\n" +
                "      \"c\"\n" +
                "   ],\n" +
                "   \"address\": {\n" +
                "      \"city\": \"GuangZhou\",\n" +
                "      \"pro\": \"GuangDong\"\n" +
                "   }\n" +
                "}";

        Assert.assertEquals(expect, JsonUtils.format(json));
  • 属性过滤
        String json = "{\"name\":\"mi米\",\"age\":30,\"weight\":100.1,\"Children\":[\"a\",\"b\",\"c\"],\"address\":{ \"city\":\"GuangZhou\",\"pro\":\"GuangDong\"}}";

        Assert.assertEquals("{\"name\":\"mi米\",\"weight\":100.1,\"address\":{ \"city\":\"GuangZhou\" }",
                JsonUtils.removeProperty(json, new String[]{"name", "weight", "address.city"}, true));

About

json相关工具包,如:json格式化、属性过滤等

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%
Morty Proxy This is a proxified and sanitized view of the page, visit original site.