fastjson JSONValidator 识别部分带注解的JSON失败

ilmyapht  于 2021-11-27  发布在  Java
关注(0)|答案(0)|浏览(691)

main函数例子:

public static void main(String args[]) {
String str = "{\n "interfaces": [//接口集合\n {\n "id": "@string",//主键\n "title": "@string",//接口名称\n "path": "@string",//请求路径,必填\n "method": "@string",//请求方法\n "projectId": "@string",//项目id\n "appId": "@string",//appId,用于接口,必填\n "type": "@string",//分类模块名称,必填\n "author": "@string",//接口作者\n "manual": false,//是否手动添加\n "editUid": "@string",//最近编辑的用户名\n "status": "@string",//状态:已完成done 未完成undone\n "description": "@string",//描述信息\n "reqQuery": [//url中带参请求查询参数集合\n {\n "id": "@string",//类信息\n "name": "@string",//字段命名\n "type": "@string",//接口返回类型的类名(不包含包名) 比如:User\n "fullType": "@string",//接口返回类型的类名(包含包名)\n "value": "@string",//具体值\n "example": "@string",//示例值\n "required": false,//是否必须\n "description": "@string",//描述\n "cls": "@string",//类信息\n "children": [//字段为类时,此时该类内部的字段集合\n {}\n ],\n "hasChildren": false,//是否有孩子\n "defaultValue": "@string"//默认值\n }\n ],\n "reqHeaders": [//请求头\n {\n "id": "@string",//类信息\n "name": "@string",//字段命名\n "type": "@string",//接口返回类型的类名(不包含包名) 比如:User\n "fullType": "@string",//接口返回类型的类名(包含包名)\n "value": "@string",//具体值\n "example": "@string",//示例值\n "required": false,//是否必须\n "description": "@string",//描述\n "cls": "@string",//类信息\n "children": [//字段为类时,此时该类内部的字段集合\n {}\n ],\n "hasChildren": false,//是否有孩子\n "defaultValue": "@string"//默认值\n }\n ],\n "reqParams": [//请求路径参数\n {\n "id": "@string",//类信息\n "name": "@string",//字段命名\n "type": "@string",//接口返回类型的类名(不包含包名) 比如:User\n "fullType": "@string",//接口返回类型的类名(包含包名)\n "value": "@string",//具体值\n "example": "@string",//示例值\n "required": false,//是否必须\n "description": "@string",//描述\n "cls": "@string",//类信息\n "children": [//字段为类时,此时该类内部的字段集合\n {}\n ],\n "hasChildren": false,//是否有孩子\n "defaultValue": "@string"//默认值\n }\n ],\n "reqBodyType": "@string",//请求体类型 enum ['form', 'json', 'text', 'file', 'raw']\n "reqBodyIsJsonSchema": false,//请求体是否json格式的数据\n "reqBodyForm": [//表单参数\n {\n "id": "@string",//类信息\n "name": "@string",//字段命名\n "type": "@string",//接口返回类型的类名(不包含包名) 比如:User\n "fullType": "@string",//接口返回类型的类名(包含包名)\n "value": "@string",//具体值\n "example": "@string",//示例值\n "required": false,//是否必须\n "description": "@string",//描述\n "cls": "@string",//类信息\n "children": [//字段为类时,此时该类内部的字段集合\n {}\n ],\n "hasChildren": false,//是否有孩子\n "defaultValue": "@string"//默认值\n }\n ],\n "reqBodyJson": [//json请求体\n {\n "id": "@string",//类信息\n "name": "@string",//字段命名\n "type": "@string",//接口返回类型的类名(不包含包名) 比如:User\n "fullType": "@string",//接口返回类型的类名(包含包名)\n "value": "@string",//具体值\n "example": "@string",//示例值\n "required": false,//是否必须\n "description": "@string",//描述\n "cls": "@string",//类信息\n "children": [//字段为类时,此时该类内部的字段集合\n {}\n ],\n "hasChildren": false,//是否有孩子\n "defaultValue": "@string"//默认值\n }\n ],\n "reqBodyOther": "@string",\n "resBodyType": "@string",//响应体类型 enum ['json', 'text', 'xml', 'raw', 'json-schema']\n "resBody": "@string",//响应体\n "resBodyIsJsonSchema": false,//响应体是否json数据格式\n "apiOpened": false,//是否开放接口\n "mock": {},//mock数据,JSONObject\n "index": 1,//索引\n "tag": [//标签\n "@string"\n ],\n "createTime": 0,//创建时间\n "updateTime": 0//更新时间\n }\n ],\n "syncToIdsaas": false//是否将接口同步到idsaas资源管理模块\n}\n";
str = str.substring(0, str.length() - 1);
System.out.println(str);
System.out.println(JSONValidator.from(str).validate());
System.out.println(JSON.isValid(str));
System.out.println(JSON.parseObject(str));
}

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题