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. pwnable.tw start&orw

    emm,之前一直想做tw的pwnable苦于没有小飞机(,今天做了一下发现都是比较硬核的pwn题目,对于我这种刚入门?的菜鸡来说可能难度刚好(orz 1.start 比较简单的一个栈溢出,给出一个li ...

  2. hibernate 一对多 取多方数据重复问题,FetchMode.JOIN、FetchMode.SELECT、FetchMode.SUBSELECT区别

    问题描述:稿件附件表数据时出现多条重复数据. 介绍: 表:稿件实体Manuscripts (数据库表MANUSCRIPTS),稿件附件实体ManuscriptsAtt(表MANUSCRIPTS_ATT ...

  3. Xshell 连接虚拟机出现 "The remote SSH server rejected X11 forwarding request"

    1. 描述 虚拟机:VirtualBox Linux: centOS7 解决了 centOS7在VirtualBox中装好后的网络连接问题 后,用 Xshell 连接服务器时出现下面情况: 2. ss ...

  4. C# 关于X86/X64/AnyCpu 的关系

    电脑硬件CPU可以分为x86与x64, x86的机器只能安装32位的操作系统,如XP, WIN7_86, x64的机器既可以安装32位的系统,又可以安装64位的系统,只是在x64的机器上安装32位的系 ...

  5. selenium对百度进行登录注销

    #百度登录退出demo import time from selenium import webdriver from selenium.webdriver.common.action_chains ...

  6. ASP.NET Core微服务 on K8S学习笔记(第一章:详解基本对象及服务发现)

    课程链接:http://video.jessetalk.cn/course/explore 良心课程,大家一起来学习哈! 任务1:课程介绍 任务2:Labels and Selectors 所有资源对 ...

  7. C# Aspose.Cells 如何设置单元格样式

    //Instantiating a Workbook object Workbook workbook = new Workbook(); //Adding a new worksheet to th ...

  8. 《物联网框架ServerSuperIO教程》- 23.动态数据接口增加缓存,提高数据输出到OPCServer和(实时)数据库的效率

     22.1   概述及要解决的问题 设备驱动有DeviceDynamic接口,可以继承并增加新的实时数据属性,每次通讯完成后更新这些属性数据.原来是通过DeviceDynamic接口实体类反射的方式获 ...

  9. 看了这一张GIF图你就明白什么回事了,必看的经典!--快速构建一个请假流程

    下面介绍一下FSBPM构建一个请假单流程 1.数据模型的构建 输入业务中需要的数据项即可,比如[申请人,开始时间,结束时间,请假天数,请假理由,附件上传..........] 2.自定义流程 审批节点 ...

  10. 使用Nexus搭建私有Nuget仓库

    前言 Nuget是ASP .NET Gallery的一员,是免费.开源的包管理工具,专注于在.Net / .Net Core应用开发过程中第三方组件库的管理,相对于传统单纯的dll引用要方便.科学得多 ...