gson

Gson deserializes with empty fields

二次信任 提交于 2020-11-29 08:54:31
问题 The result variable contains corrected parsed JSON. But after deserialization List contains correct amount of items but all of them are empty. How to fix it? Gson gson = new Gson(); List<UnitView> unitViews = new ArrayList<UnitView>(); // https://stackoverflow.com/questions/5554217/google-gson-deserialize-listclass-object-generic-type Type typeToken = new TypeToken<List<UnitView>>() { }.getType(); unitViews = gson.fromJson(result,typeToken); Even if I do like UnitView[] unitViews = gson

Gson deserializes with empty fields

為{幸葍}努か 提交于 2020-11-29 08:53:41
问题 The result variable contains corrected parsed JSON. But after deserialization List contains correct amount of items but all of them are empty. How to fix it? Gson gson = new Gson(); List<UnitView> unitViews = new ArrayList<UnitView>(); // https://stackoverflow.com/questions/5554217/google-gson-deserialize-listclass-object-generic-type Type typeToken = new TypeToken<List<UnitView>>() { }.getType(); unitViews = gson.fromJson(result,typeToken); Even if I do like UnitView[] unitViews = gson

Gson deserializes with empty fields

余生颓废 提交于 2020-11-29 08:53:06
问题 The result variable contains corrected parsed JSON. But after deserialization List contains correct amount of items but all of them are empty. How to fix it? Gson gson = new Gson(); List<UnitView> unitViews = new ArrayList<UnitView>(); // https://stackoverflow.com/questions/5554217/google-gson-deserialize-listclass-object-generic-type Type typeToken = new TypeToken<List<UnitView>>() { }.getType(); unitViews = gson.fromJson(result,typeToken); Even if I do like UnitView[] unitViews = gson

第二个android小项目-模仿百度网盘实现一些功能

ⅰ亾dé卋堺 提交于 2020-11-28 13:53:41
写这个项目是为了继续打打android的基础,另外还了解到了一些新方法和小技巧所以想来用用练练手,比如调用百度api来访问个人百度网盘中的头像名称项目文件等等,继续深入还可以在App中修改个人百度网盘中的文件。 话不多说直接开始项目所需要用到的图片资源 点这里 https://github.com/JackySei/baiduimg.git 结构是 首先是登录界面 只是主观简单的模仿了一下,可能有点丑。 activity_main < ? xml version = "1.0" encoding = "utf-8" ? > < androidx . constraintlayout . widget . ConstraintLayout xmlns : android = "http://schemas.android.com/apk/res/android" xmlns : app = "http://schemas.android.com/apk/res-auto" xmlns : tools = "http://schemas.android.com/tools" android : layout_width = "match_parent" android : layout_height = "match_parent" tools : context = "

springBoot @EnableAutoConfiguration深入分析

非 Y 不嫁゛ 提交于 2020-11-27 01:44:39
1、新建一个项目中需要提供配置类 2、 在 META-INF/spring.factorties 在文件中配置   org.springframework.boot.autoconfigure.EnableAutoConfiguration=\   第三方 jar 中提供配置类全路径 实例演示: bean-core 工程: package com.boot.config.core.domain; public class Order { } package com.boot.config.core.domain; public class Product { } package com.boot.config.core.config; import com.boot.config.core.domain.Order; import com.boot.config.core.domain.Product; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @Configuration public class BeanConfiguration { @Bean public Order createOrder(

SpringBoot返回JSON

亡梦爱人 提交于 2020-11-25 06:31:35
[TOC] 1、SpringBoot返回JSON简介 随着web开发前后端分离技术的盛行,json是目前主流的前后端数据交互方式,使用json数据进行交互需要对json数据进行转换解析,需要用到一些json处理器,常用的json处理器有: jackson-databind,SpringBoot默认的json处理器 Gson,是Google的一个开源框架 fastjson,目前解析速度最快的开源解析框架,由阿里开发 下面分别介绍如何在SpringBoot中整合三大json解析框架。 2、整合jackson-databind Jackson-databind是SpringBoot默认集成在web依赖中的框架,因此我们只需要引入 spring-boot-starter-web 依赖,就可以返回json数据: 接着上篇文章中的demo继续修改demo,先看下代码框架: 下面开始修改demo,返回json数据,首先在pojo下创建一个Good实体类,并且可以通过注解来解决日期格式等需求: package com.gongsir.springboot02.pojo; import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonIgnore; import java

Springboot 之基于 Serverless 的订单应用

99封情书 提交于 2020-11-23 19:17:13
前言 这是一个 JAVA 开发的订单后台应用(没错!就是那个让无数大学生痛不欲生的订单后台系统),结合 Serverless 这一无服务器思想,尝试通过云函数 + API 网关 + 云数据库的组合来部署 Springboot 的成功之作。 本文作者:Freeeeeedom 该应用提供了完整的用户登录验证、接口数据验证、订单流 (CRUD) 等强大的功能,而且在本地开发调试时也能模拟 API 网关调用云函数(本地 Java 开发云端部署不是问题),还兼容了云消息队列 CMQ 的调用,以便后续开发引入云中间件。 同时,这种部署方式也能让其他的 Springboot 很快地转换为云函数部署。 为响应国家「十四五计划」的环保计划,特地的研究了一下传说中的 Serverless 方案(省服务器 😄),于是便有了这次尝试。 语言和框架 JAVA 天下第一**,当然 c/c++/c#/node/python/go/php/vb 这些也不错 JAVA 的单体应用还能选什么呢?只能是 Springboot 啊 部署准备 注册个腾讯云账号 开通以下产品权限(云函数、API 网关、对象存储) 财力允许的话还可以购买数据库服务(因为年少轻狂打折时我购买了这俩很长很长时间) mysql数据库 redis数据库 部署方案 订单应用来说的话,必然是提供 restful 的接口,所以在统一 VPC 内采用了云函数

阿里云短信验证_基于阿里云OpenAPI实现

倖福魔咒の 提交于 2020-11-23 05:38:12
阿里云短信服务 背景简介: 短信验证以及短信通知,目前已经应用的非常广泛,最近因项目需要,需要将原来的短信接口换成阿里云的的短信服务,原项目集成的短信服务能够实现短信的发送以及短信的验证整个过程,简单的来说,原来的短息服务,只需应用申请获取短信,短息服务器会发送短信到指定的手机,用户将验证码发送到短信服务商的服务器,服务器做出验证返回是否通过,而阿里云仅提供短信发送服务,需要自己开发短信的验证。下面简单的介绍一下: 1.获取阿里云AccessKey 用户->Accesskeys:需要自己创建一个AccessKey 2.创建短信签名: 阿里云控制台->短信服务->国内短信->签名管理: 创建自己的签名(签名主要是指应用的名字,如:中国移动,建设银行) 3.创建短信模板: 国内短信->模板管理:创建自己的短信通知模板(如:您正在申请手机注册,验证码为:${code},5分钟内有效!) 4.基于阿里云openAPI实现短信发送模块 注意:这里项目中需要导入aliyun-java-sdk-core-4.1.0.jar,额外注意:javaweb项目中,需要将aliyun-java-sdk-core-4.1.0.jar 以及gson-2.8.5.jar 导入到tomcat 的lib目录下,不然会出错。 1 package Surpport; 2 import com.aliyuncs