# JSON **Repository Path**: relin/JSON ## Basic Information - **Project Name**: JSON - **Description**: Android JSON Map List Array Object String互转 - **Primary Language**: Java - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2022-06-20 - **Last Updated**: 2023-09-21 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # JSON Android Json工具 如果是java项目使用,请先下载org.json.jar依赖在使用JSON ## ARR |名称|操作| |-|-| |Github-JSON|[查看](https://github.com/RelinRan/JSON) | |Gitee-JSON|[查看](https://gitee.com/relin/JSON) | |json.jar|[下载](https://github.com/RelinRan/JSON/blob/master/jar) | |org.json.jar|[下载](https://github.com/RelinRan/JSON/blob/master/jar) | ## JitPack /build.grade ``` allprojects { repositories { ... maven { url 'https://jitpack.io' } } } ``` /app/build.grade ``` dependencies { implementation 'com.github.RelinRan:JSON:2023.9.1.2' } ``` #### Debug ``` JSON json = new JSON(); //设置调试模式,调试错误使用 json.setDebug(true); ``` #### Object ``` //Object -> JSON String json = json.toJson(object); //JSON -> Object User user = json.toObject(json,User.class); ``` #### Array ``` String[] array = json.toArray(json,String.class); ``` #### List ``` List list = json.toList(json,User.class); List list = json.toList(json,String.class); ``` #### Collection ``` ArrayList list = json.toCollection(json,ArrayList.class,User.class); Stack list = json.toCollection(json,Stack.class,User.class); Vector list = json.toCollection(json,Vector.class,User.class); Collection decode = json.toCollection(json,Collection.class,String.class); ``` #### T ``` //多个泛型 Map> variable = new HashMap<>(); variable.put("data",Data.class); User user = json.toObject(json,user,variable); //单个泛型 User user = json.toObject(json,User.class,"data",Data.class); ``` #### Map ``` Map map = json.toMap(json); ``` #### List Map ``` List> listMap = json.toMapCollection(json); ```