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对象
随机推荐
- c# 利用IEqualityComparer接口去除DataTable重复数据
IEqualityComparer主要适用于定义方法以支持对象的相等比较.可以实现集合的自定义相等比较.即,您可以创建自己的相等定义,并指定此定义与接受 IEqualityComparer 接口的集合 ...
- mybatis调用oracle存储过程的几个参考例子
首先写一个存储过程: create or replace procedure p_syn_equipment_20161205 is sqlstr ); begin --清空表 sqlstr := ' ...
- 【easy】268. Missing Number
Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missin ...
- cookie记录横向滚动条位置
一.Css <style type="text/css"> #x{ width: 100%; white-space: nowrap; overflow-x: scro ...
- 解决exlipse下 springboot 错误:找不到或无法加载主类
简单描述:控制台出现了下图 废话不多说,直接上解决办法: 方法一:如果你很有自信,自己的pom 没问题,并且已经加载了所有依赖的jar.ok,这是eclipse的问题,window=>prefe ...
- Python深度学习(Deep Learning with Python) 中文版+英文版+源代码
Keras作者.谷歌大脑François Chollet最新撰写的深度学习Python教程实战书籍(2017年12月出版)介绍深入学习使用Python语言和强大Keras库,详实新颖.PDF高清中文版 ...
- WPF使用CefSharp嵌入网页
1.点击项目应用下的管理NuGet程序包 2.在浏览中输入cefsharp-->查找 CefSharp.Wpf-->点击安装,等待安装完成 3.如果遇到一下问题将解决方案和项目都改成64位 ...
- 2018-2019-2 20165206《网络对抗技术》Exp1 PC平台逆向破解
- 2018-2019-2 20165206<网络对抗技术>Exp1 PC平台逆向破解 - 实验任务 本次实践的对象是一个名为pwn1的linux可执行文件. 该程序正常执行流程是:mai ...
- cmake让add_subdirectory()的所有target生成到同一目录
问题描述和解决办法 整个项目包括: 库.测试程序,都是基于源码生成:测试程序肯定是executable类型了,而如果生成的库是SHARED类型,在windows下就是.dll(以及对应的.lib)文件 ...
- [原创]X-HDL 4.2安装与使用
由于涉及到VHDL工程,但实际工作中,用Verilog更多些,因此安装X-HDL进行转换,安装步骤与使用如下: X-HDL进行破解,破解如下: 安装完毕后,打开一个带转换的文件,进行如下操作: 链接: ...