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数组的更多相关文章

  1. JS解析json数据并将json字符串转化为数组的实现方法

    json数据在ajax实现异步交互时起到了很重要的作用,他可以返回请求的数据,然后利用客户端的js进行解析,这一点体现出js的强大,本文介绍JS解析json数据并将json字符串转化为数组的实现方法, ...

  2. Gson解析json字符串、json数组转换成对象

    实体类: public class Product { private int id; private String name; private String date; public int get ...

  3. JSON.stringify()方法是将一个javascript值(对象或者数组)转换成为一个JSON字符串;JSON.parse()解析JSON字符串,构造由字符串描述的javascript值或对象

    JSON.stringify()方法是将一个javascript值(对象或者数组)转换成为一个JSON字符串:JSON.parse()解析JSON字符串,构造由字符串描述的javascript值或对象

  4. jquery字符串数组转json字符串 C#json字符串转字符串list

    一.jquery字符串数组转json字符串 var str=['1','2','3']; var jsonText= JSON.stringify(str);//把一个对象转换成json字符串 str ...

  5. 做筛选遍历时遇到的json字符串、json对象、json数组 三者之间的转换问题

    这个是后台对登录用户以及筛选条件的操作 @Override public List<SdSdPer> listResults(String sidx, String sord) { try ...

  6. Python解析json字符串,json字符串用法

    json数据简介 json数据是一个轻量级的数据交换格式,采用完全独立于语言的文本格式,这些特性使json称为理想的数据交换语言,易于人阅读和编写,同时易于机器解析和生成. json中的字符集必须是U ...

  7. java 判断String字符串是不是json数据

      java 判断String字符串是不是json数据 CreationTime--2018年8月24日18点23分 Author:Marydon JSONObject jo = null; try ...

  8. jsoncpp构造json字符串和json数组

    jsoncpp构造json字符串和json数组 参考文章:Jsoncpp的简单使用 下载json文件夹放在c++项目的include目录下,在CMakeLists中include进去,然后就可以在代码 ...

  9. 转换成json字符串,与json字符串转换成java类型都要先转换成json对象

    转换成json字符串,与json字符串转换成java类型都要先转换成json对象

随机推荐

  1. 【interview——Ali】project interview_18 summer

    完全没有准备的一次面试……意外 两部分:Word2vec + 中位数 (还有聊对科研的想法和自己研究能力的评价? word2vec //解释模型 原本是one-hot,存在缺点:稀疏和无法表现语义,词 ...

  2. msdn原版系统和原版office

    建议使用迅雷下载工具进行下载 激活详见:在线激活win10.win8/8.1和office2019.2016.2013等的kms激活工具 windows 10 家庭版/家庭单语言版/专业版/教育版/专 ...

  3. 【Selenium】各浏览器(firefox,chrome,ie)驱动下载地址汇总

    前两天使用Selenium分布式时,总抛出异常.更新成最新驱动可以解决.其中chrome异常如下, "platform": "WINDOWS" File &qu ...

  4. 中小学Python编程语言教学

    中小学Python编程语言教学 作为一名高中信息技术老师,被技术的发展潮流推动着,不断更新教学内容和方法,以适应快速发展的信息社会. 以前的中小学信息技术课程,老师们各显神通,身怀绝技,教PS,Fal ...

  5. verilog function功能函数写法

    :] sm2tc; :] din; :] dp; :] dn; :] dout; begin dp = {'b0, din[14:0]}; dn = ~dp + 'b1; dout = (din[] ...

  6. 4.1 ORACLE DATAGUARD SWITCHOVER 步骤

    验证主库是否能执行角色转换到备库 原主库执行 SQL> SELECT SWITCHOVER_STATUS FROM V$DATABASE; SWITCHOVER_STATUS --------- ...

  7. Ubuntu18.04,安装Redis配置远程连接访问和简单使用Redis

    前言 Redis是常用基于内存的Key-Value数据库,比Memcache更先进,支持多种数据结构,高效,快速.用Redis可以很轻松解决高并发的数据访问问题:作为实时监控信号处理也非常不错. 环境 ...

  8. centos 7.5+如何格式化硬盘

    [root@k8s-node2 ~]# fdisk -l Disk /dev/sdb: bytes, sectors Units = sectors of * = bytes Sector size ...

  9. 关于vue的computed、filters、watch

    filters 这个属性大家可能用的不是很多 因为一般的数组过滤我们用 es6的filter就能完成了 我想到一个场景,网上买书促销 满100减50 满两百减100 <input type=&q ...

  10. C++ 生成洛伦兹的蝴蝶

    这里使用 C++ 计算轨迹,生成 Python 文件,使用 matplotlib 绘图. // simulator.cpp : 此文件包含 "main" 函数.程序执行将在此处开始 ...