Java解析json字符串和json数组
Java解析json字符串和json数组
public static Map<String, String> getUploadTransactions(String json){
Map<String, String> map = new HashMap<String, String>();
JsonParser jsonParser = new JsonParser();
JsonObject jsonObject = (JsonObject)jsonParser.parse(json);
String sha1 = jsonObject.get("sha1").getAsString();
String storekey = jsonObject.get("storekey").getAsString();
map.put("sha1", sha1);
map.put("storekey", storekey);
return map;
}
public static Map<String, String> getReturenTransactionCode(String json){
Map<String, String> map = new HashMap<String, String>();
JsonParser jsonParser = new JsonParser();
JsonObject jsonObject = (JsonObject)jsonParser.parse(json);
String id = jsonObject.get("id").getAsString();
map.put("id", id);
String feedback = jsonObject.get("feedback").getAsString();
map.put("feedback", feedback);
JsonObject file_hashes_JsonObject = jsonObject.get("file_hashes").getAsJsonObject();
String sha1 = file_hashes_JsonObject.get("sha1").getAsString();
map.put("sha1", sha1);
JsonArray upload_requests_jsonArray = jsonObject.get("upload_requests").getAsJsonArray();
JsonObject upload_requests_jsonArray_jsonObject = upload_requests_jsonArray.get(0).getAsJsonObject();
String type = upload_requests_jsonArray_jsonObject.get("type").getAsString();
map.put("type", type);
JsonObject request_jsonObject = upload_requests_jsonArray_jsonObject.get("request").getAsJsonObject();
String method = request_jsonObject.get("method").getAsString();
map.put("method", method);
String url = request_jsonObject.get("url").getAsString();
map.put("url", url);
JsonArray header_array = request_jsonObject.get("header").getAsJsonArray();
for (int i = 0; i < header_array.size(); i++) {
JsonObject heard_JsonObject = header_array.get(i).getAsJsonObject();
String header_name = heard_JsonObject.get("name").getAsString();
String header_value = heard_JsonObject.get("value").getAsString();
map.put(header_name, header_value);
}
return map;
}
public static Map<String, String> getSomeValumesCode(String json) {
Map<String, String> map = new HashMap<String, String>();
JsonParser jsonParser = new JsonParser();
JsonObject jsonObject = (JsonObject)jsonParser.parse(json);
JsonArray array = jsonObject.get("value").getAsJsonArray();
JsonObject object = array.get(0).getAsJsonObject();
String code = object.get("id").getAsString();
String name = object.get("name").getAsString();
String type = object.get("type").getAsString();
map.put("id", code);
map.put("name", name);
map.put("type", type);
return map;
}
public static Integer getVolumesId(String json) {
int valumesId = 0 ;
JsonParser jsonParser = new JsonParser();
JsonObject jsonObject = (JsonObject)jsonParser.parse(json);
JsonArray array = jsonObject.get("value").getAsJsonArray();
for (int i = 0; i < array.size(); i++) {
JsonObject object = array.get(0).getAsJsonObject();
valumesId = object.get("id").getAsInt();
String name = object.get("name").getAsString();
//System.out.println(name);
}
return valumesId;
}
http://graph.rst.ricoh.com/oauth2/token
{
"access_token": "czNcAISIJJLCy30XN9eYXjg6fm5IT6of_An7F2kt3eI.AAdG9BnhS6cZowQ_sUaBtEO-78wW-bxTsoZ_H9vu-Sg",
"expires_in": 3599,
"scope": "User.Files.Read User.Files.ReadWrite",
"token_type": "bearer"
}
http://graph.rst.ricoh.com/api/v1/me/volumes
{
"value": [
{
"id": "4053",
"name": "我的文档",
"company_id": "1",
"created_by": {
"user": {
"id": "11"
}
},
"created_at": "2019-04-03T13:30:59+08:00",
"updated_by": {
"user": {
"id": "11"
}
},
"updated_at": "2019-04-19T17:12:05+08:00"
},
{
"id": "4054",
"name": "自动上传文档",
"company_id": "1",
"created_by": {
"user": {
"id": "11"
}
},
"created_at": "2019-04-03T13:30:59+08:00",
"updated_by": {
"user": {
"id": "11"
}
},
"updated_at": "2019-04-03T13:30:59+08:00"
}
]
} http://graph.rst.ricoh.com/api/v1/me/volumes/4053 {
"id": "4053",
"name": "我的文档",
"company_id": "1",
"created_by": {
"user": {
"id": "11"
}
},
"created_at": "2019-04-03T13:30:59+08:00",
"updated_by": {
"user": {
"id": "11"
}
},
"updated_at": "2019-04-19T17:12:05+08:00"
} http://graph.rst.ricoh.com/api/v1/me/volumes/4053/files/root/children {
"value": [
{
"id": "4077",
"name": "hbx",
"type": "folder",
"size": 0,
"volume_id": "4053",
"parent_id": "root",
"hashes": {
"sha1": ""
},
"created_by": {
"user": {
"id": "11"
}
},
"created_at": "2019-04-19T17:13:10+08:00",
"updated_by": {
"user": {
"id": "11"
}
},
"updated_at": "2019-04-19T17:13:10+08:00",
"path": ""
},
{
"id": "4073",
"name": "web.config",
"type": "regular",
"size": 75,
"volume_id": "4053",
"parent_id": "root",
"hashes": {
"sha1": "9cdf005be86a5e354b6311176e453e9e7875cdfe"
},
"created_by": {
"user": {
"id": "11"
}
},
"created_at": "2019-04-19T16:30:00+08:00",
"updated_by": {
"user": {
"id": "11"
}
},
"updated_at": "2019-04-19T16:30:00+08:00",
"path": ""
}
]
} http://graph.rst.ricoh.com/api/v1/me/volumes/4053/files/root/children {
"id": "4077",
"name": "hbx",
"type": "folder",
"size": 0,
"volume_id": "4053",
"parent_id": "root",
"hashes": {
"sha1": ""
},
"created_by": {
"user": {
"id": "11"
}
},
"created_at": "2019-04-19T17:13:10+08:00",
"updated_by": {
"user": {
"id": "11"
}
},
"updated_at": "2019-04-19T17:13:10+08:00",
"path": ""
} http://graph.rst.ricoh.com/api/v1/me/volumes/4053/files/4077/upload-transactions {
"id": "35233b59-ae97-4496-5672-bca8b2128c81",
"storage": "s3",
"file_hashes": {
"sha1": "1e4002375dd8ba806ced48f6464bb7f1995659f8"
},
"feedback": "4oRDGQ8kfRhbLoxaf7XvD1WV4dE=.eyJ0cmFuc2FjdGlvbl9pZCI6IjM1MjMzYjU5LWFlOTctNDQ5Ni01NjcyLWJjYThiMjEyOGM4MSIsInN0b3JhZ2VfdHlwZSI6InMzIiwiaXNfZmlsZV91cGRhdGUiOmZhbHNlLCJmaWxlX2lkIjowLCJmaWxlX25hbWUiOiJKYXZh5YWl6Zeo57uP5YW477yI5by654OI5o6o6I2Q77yJLnBkZiIsImZpbGVfbmFtZV9jb25mbGljdF9iZWhhdmlvciI6Im92ZXJ3cml0ZSIsImZpbGVfc2l6ZSI6MjkzODc3MSwiZmlsZV9oYXNoZXMiOnsic2hhMSI6IjFlNDAwMjM3NWRkOGJhODA2Y2VkNDhmNjQ2NGJiN2YxOTk1NjU5ZjgifSwiZmlsZV9rZXkiOiIzNTIzM2I1OS1hZTk3LTQ0OTYtNTY3Mi1iY2E4YjIxMjhjODEiLCJtdWx0aXBhcnRfdXBsb2FkX2lkIjoiIn0=",
"upload_requests": [
{
"type": "put_object",
"request": {
"method": "PUT",
"url": "http://wps.rst.ricoh.com/minio/wpsfile/35233b59-ae97-4496-5672-bca8b2128c81",
"header": [
{
"name": "Content-Type",
"value": "application/octet-stream"
},
{
"name": "Authorization",
"value": "AWS4-HMAC-SHA256 Credential=LTAIf5lqDRk6W4Mf/20190419/us-east-1/s3/aws4_request,SignedHeaders=host;x-amz-content-sha256;x-amz-date,Signature=1e83c6d9f5efa07282988e09fca1f727f4028bd05b24a6c34886a9a18f0568f4"
},
{
"name": "x-amz-content-sha256",
"value": "UNSIGNED-PAYLOAD"
},
{
"name": "x-amz-date",
"value": "20190419T094657Z"
}
]
}
}
]
} http://wps.rst.ricoh.com/minio/wpsfile/35233b59-ae97-4496-5672-bca8b2128c81 {
"sha1": "a5abef21fe1e603f9bb419b23ea4d96b9615c66e",
"storekey": "35233b59-ae97-4496-5672-bca8b2128c81"
} http://graph.rst.ricoh.com/api/v1/me/volumes/4053/files/4077/upload-transactions/35233b59-ae97-4496-5672-bca8b2128c81 {
"id": "35233b59-ae97-4496-5672-bca8b2128c81",
"storage": "s3",
"file_hashes": {
"sha1": "1e4002375dd8ba806ced48f6464bb7f1995659f8"
},
"status": "commited",
"file": {
"id": "4078",
"name": "Java入门经典(强烈推荐).pdf",
"type": "regular",
"size": 2938771,
"volume_id": "4053",
"parent_id": "4077",
"hashes": {
"sha1": "1e4002375dd8ba806ced48f6464bb7f1995659f8"
},
"created_by": {
"user": {
"id": "11"
}
},
"created_at": "2019-04-19T17:48:22+08:00",
"updated_by": {
"user": {
"id": "11"
}
},
"updated_at": "2019-04-19T17:48:22+08:00",
"path": ""
}
}
Java解析json字符串和json数组的更多相关文章
- JS解析json数据并将json字符串转化为数组的实现方法
json数据在ajax实现异步交互时起到了很重要的作用,他可以返回请求的数据,然后利用客户端的js进行解析,这一点体现出js的强大,本文介绍JS解析json数据并将json字符串转化为数组的实现方法, ...
- Gson解析json字符串、json数组转换成对象
实体类: public class Product { private int id; private String name; private String date; public int get ...
- JSON.stringify()方法是将一个javascript值(对象或者数组)转换成为一个JSON字符串;JSON.parse()解析JSON字符串,构造由字符串描述的javascript值或对象
JSON.stringify()方法是将一个javascript值(对象或者数组)转换成为一个JSON字符串:JSON.parse()解析JSON字符串,构造由字符串描述的javascript值或对象
- jquery字符串数组转json字符串 C#json字符串转字符串list
一.jquery字符串数组转json字符串 var str=['1','2','3']; var jsonText= JSON.stringify(str);//把一个对象转换成json字符串 str ...
- 做筛选遍历时遇到的json字符串、json对象、json数组 三者之间的转换问题
这个是后台对登录用户以及筛选条件的操作 @Override public List<SdSdPer> listResults(String sidx, String sord) { try ...
- Python解析json字符串,json字符串用法
json数据简介 json数据是一个轻量级的数据交换格式,采用完全独立于语言的文本格式,这些特性使json称为理想的数据交换语言,易于人阅读和编写,同时易于机器解析和生成. json中的字符集必须是U ...
- java 判断String字符串是不是json数据
java 判断String字符串是不是json数据 CreationTime--2018年8月24日18点23分 Author:Marydon JSONObject jo = null; try ...
- jsoncpp构造json字符串和json数组
jsoncpp构造json字符串和json数组 参考文章:Jsoncpp的简单使用 下载json文件夹放在c++项目的include目录下,在CMakeLists中include进去,然后就可以在代码 ...
- 转换成json字符串,与json字符串转换成java类型都要先转换成json对象
转换成json字符串,与json字符串转换成java类型都要先转换成json对象
随机推荐
- Decode String
Given an encoded string, return it's decoded string.The encoding rule is: k[encoded_string], where t ...
- 嵌入式Linux学习路线
最近比较忙,对于嵌入式的相关学习一直没有很好的开展.今天也看了不少的嵌入式Linux的学习路线,也和几个工作过的朋友聊了聊,想把之后的学习过程记录下来. 自己以后想从事驱动开发这方面的工作,因为大多数 ...
- maven父子模块deploy 问题
1.问题描述:直接 deploy 子某块,但第三者确不能引用 jar(jar down不下来,但pom不报错) 原因:父子模块项目必须保证父模块pom deploy后,再 deploy 子模块才能被引 ...
- 高可用Redis(四):列表,集合与有序集合
1.列表类型 1.1 列表数据结构 左边为key,是字符串类型 右边为value,是一个有序的队列,与python的列表结构相同 可以在Redis中对列表的value进行如下操作 从左边添加元素 从右 ...
- Clipboard---将文本复制到剪切板上
第一步:链接 Clipboard 的js文件 < script src = “ https://cdn.jsdelivr.net/npm/clipboard@2/dist/clipboard.m ...
- md5加密 bas64加密
/** * 获取bas64加密的算法 * @param str * @return */ public static String getBase64(String str) { byte[] b = ...
- form 表单提交数据 不跳转解决办法
1. 利用隐藏的 iframe —— 只需form的 target 指向iframe的name:可不用form 的action默认提交,自己写ajax 提交数据. <html> < ...
- node 和 npm 常用命令
npm node 简述 快速入门 安装npm和管理npm版本 npm安装 更新npm npm -v npm install npm@latest -g npm install npm@next -g ...
- Useful Git Commands for me
查看Git追踪的文件 git ls-files 移除远程仓库的文件夹 git rm -r --cached some-directory git commit -m "Remove th ...
- 《连载 | 物联网框架ServerSuperIO教程》- 16.集成OPC Server,及使用步骤。附:3.3 发布与版本更新说明。
1.C#跨平台物联网通讯框架ServerSuperIO(SSIO)介绍 <连载 | 物联网框架ServerSuperIO教程>1.4种通讯模式机制. <连载 | 物联网框架Serve ...