目录

1 jackson json基本介绍和使用

网上有很多关于jackson和json的介绍和使用,我就不重复造轮子了,本篇博客主要介绍jackson的高级应用和博主我自己踩坑心得。

如果对json和jackson不熟悉的朋友,可以看下面两篇博客。

https://www.runoob.com/json/json-tutorial.html JSON教程

https://blog.csdn.net/u011054333/article/details/80504154#commentBox jackson快速入门

2 jackson 常用的注解

2.1@JsonProperty

这个注解非常有用,看下面代码:

  1. public class Person {
  2. @JsonProperty("username")
  3. private String name;
  4. private Integer age;
  5. //省略getter setter
  6. }
  1. @Test
  2. public void test1() throws Exception{
  3. ObjectMapper mapper = new ObjectMapper();
  4. Person person = new Person("adai",21);
  5. System.out.println(mapper.writeValueAsString(person));
  6. }

输出为 {"age":21,"username":"adai"}

可以看到,在序列化的json串中,username替代了name

2.2 @JsonIgnore

  1. public class Person {
  2. @JsonIgnore
  3. private String name;
  4. private Integer age;
  5. //省略getter setter
  6. }
  1. @Test
  2. public void test1() throws Exception{
  3. ObjectMapper mapper = new ObjectMapper();
  4. Person person = new Person("adai",21);
  5. System.out.println(mapper.writeValueAsString(person));
  6. }

输出为 {"age":21}

2.3 @JsonIgnoreProperties

①这个注解和@JsonIgnore有些类似,不过主要是作用在类上面

  1. @JsonIgnoreProperties(value = {"name","age"})
  2. public class Person {
  3. private String name;
  4. private Integer age;
  5. private Double height;
  6. //省略getter setter
  7. }
  1. @Test
  2. public void test1() throws Exception {
  3. ObjectMapper mapper = new ObjectMapper();
  4. Person person = new Person("adai", 21, 172D);
  5. String json = mapper.writeValueAsString(person);
  6. System.out.println(json);
  7. }

输出为 {"height":172.0}

可以看出@JsonIgnoreProperties(value = {"name","age"}) 忽略了name和age属性,在序列化的时候,会忽略这两个属性

②@JsonIgnoreProperties注解还有一个ignoreUnknown属性,主要用在反序列化上

在正常情况下,如果我们json串中有一些key值和我们的POJO对象不匹配,那么将会抛出异常。

  1. @Test
  2. public void test2() throws Exception {
  3. ObjectMapper mapper = new ObjectMapper();
  4. System.out.println(mapper.readValue(" {\"name\":\"adai\",\"age\":21,\"height222\":172.0}", Person.class));
  5. // !!注意height222与我们的pojo对象不匹配
  6. }

程序将会抛出异常

  1. com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "height222" (class com.antiy.common.adai.demo.Person), not marked as ignorable (3 known properties: "name", "age", "height"])
  2. at [Source: (String)"{"name":"adai","age":21,"height222":172.0}"; line: 1, column: 42] (through reference chain: com.antiy.common.adai.demo.Person["height222"])

此时如果我们在Person类上加上@JsonIgnoreProperties(ignoreUnknown = true)

  1. @JsonIgnoreProperties(ignoreUnknown = true)
  2. public class Person {
  3. private String name;
  4. private Integer age;
  5. private Double height;
  6. //省略getter setter
  7. }

输出为 Person(name=adai, age=21, height=null)

③使用 mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); 也可以达到同样的目的

④建议:ignoreUnknown和FAIL_ON_UNKNOWN_PROPERTIES尽量不要设置为true,如果反序列化的时候,json串中的相关key和POJO属性不匹配,就让程序抛出异常,即使发现错误,不过具体情况还需要参考具体业务,jackson默认该值为false

2.4 @JsonTypeName和@JsonTypeInfo

主要作用:在json串中又包装了一层

①正常情况下,序列化的字符串是 {"name":"adai","age":21,"height":172.0}

当我们在Person类上加上@@JsonTypeName和@JsonTypeInfo时

  1. @JsonTypeName(value = "user222")
  2. @JsonTypeInfo(include = JsonTypeInfo.As.WRAPPER_OBJECT, use = JsonTypeInfo.Id.NAME)
  3. public class Person {
  4. private String name;
  5. private Integer age;
  6. private Double height;
  7. //省略getter setter
  8. }

输出为 {"user222":{"name":"adai","age":21,"height":172.0}}

②我们也可以使用@JsonRootName("user222")和mapper.enable(SerializationFeature.WRAP_ROOT_VALUE)来达到同样的效果

  1. @JsonRootName("user222")
  2. public class Person {
  3. private String name;
  4. private Integer age;
  5. private Double height;
  6. //省略getter setter
  7. }
  1. @Test
  2. public void test1() throws Exception {
  3. ObjectMapper mapper = new ObjectMapper();
  4. mapper.enable(SerializationFeature.WRAP_ROOT_VALUE);
  5. Person person = new Person("adai", 21, 172D);
  6. System.out.println(mapper.writeValueAsString(person));
  7. }

输出为 {"user222":{"name":"adai","age":21,"height":172.0}}

2.5 @JsonFormat

主要用在Date属性上

  1. public class Person {
  2. private String name;
  3. private Integer age;
  4. private Double height;
  5. private Date date;
  6. //省略getter setter
  7. }
  1. @Test
  2. public void test1() throws Exception {
  3. ObjectMapper mapper = new ObjectMapper();
  4. Person person = new Person("adai", 21, 172D,new Date());
  5. System.out.println(mapper.writeValueAsString(person));
  6. }

输出为 {"name":"adai","age":21,"height":172.0,"date":1558842751645}

注意:jackson默认会将Date类型序列化成时间戳,这是因为SerializationFeature中的WRITE_DATES_AS_TIMESTAMPS(true),该值默认为true,当我们手动将改值设为false时。

mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);

输出为 {"name":"adai","age":21,"height":172.0,"date":"2019-05-26T03:56:38.660+0000"}

这时候date就不再是时间戳了,但是和我们中国的时间格式有一些差别,这个时候就可以使用@JsonFormat

  1. public class Person {
  2. private String name;
  3. private Integer age;
  4. private Double height;
  5. @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss:SSS",timezone="GMT+8")
  6. private Date date;
  7. //省略getter setter
  8. }

输出为 {"name":"adai","age":21,"height":172.0,"date":"2019-05-26 11:58:07:296"}

2.6 @JsonAnyGetter

该注解主要用在序列化:

1.方法是非静态,没有参数的,方法名随意

2.方法返回值必须是Map类型

3.在一个实体类中仅仅用在一个方法上

4.序列化的时候json字段的key就是返回Map的key,value就是Map的value

  1. public class Person {
  2. private String name;
  3. private Integer age;
  4. private Map<String, Object> map = new HashMap<>();
  5. public String getName() {
  6. return name;
  7. }
  8. public void setName(String name) {
  9. this.name = name;
  10. }
  11. public Integer getAge() {
  12. return age;
  13. }
  14. public void setAge(Integer age) {
  15. this.age = age;
  16. }
  17. @JsonAnyGetter // 注意这个注解
  18. public Map<String, Object> getOther(){
  19. return map;
  20. }
  21. }
  1. @Test
  2. public void test1() throws Exception {
  3. ObjectMapper mapper = new ObjectMapper();
  4. Person person = new Person();
  5. person.setName("adai");
  6. person.setAge(21);
  7. Map<String, Object> other = person.getOther();
  8. other.put("city", "chengdu");
  9. System.out.println(mapper.writeValueAsString(person));
  10. }

输出为 {"name":"adai","age":21,"city":"chengdu"}

当我们在public Map<String, Object> getOther()上去掉@JsonAnyGetter这个注解的时候

输出为 {"name":"adai","age":21,"other":{"city":"chengdu"}}

可以看出加上这个注解以后序列化的时候就会将Map里面的值也相当于实体类里面的字段给显示出来了。

2.7 @JsonAnySetter

主要作用于反序列化上

1.用在非静态方法上,注解的方法必须有两个参数,第一个是json字段中的key,第二个是value,方法名随意

2.反序列化的时候将对应不上的字段全部放到Map里面

  1. public class Person {
  2. private String name;
  3. private Integer age;
  4. private Map<String, String> map = new HashMap<>();
  5. public String getName() {
  6. return name;
  7. }
  8. public void setName(String name) {
  9. this.name = name;
  10. }
  11. public Integer getAge() {
  12. return age;
  13. }
  14. public void setAge(Integer age) {
  15. this.age = age;
  16. }
  17. @JsonAnySetter //注意这个注解
  18. public void setOther(String key, String value){
  19. this.map.put(key, value);
  20. }
  21. @Override
  22. public String toString() {
  23. return "Person{" +
  24. "name='" + name + '\'' +
  25. ", age=" + age +
  26. ", map=" + map +
  27. '}';
  28. }
  29. }
  1. @Test
  2. public void test1() throws Exception {
  3. ObjectMapper mapper = new ObjectMapper();
  4. String json = "{\"name\":\"adai\",\"age\":21,\"color\":\"red\",\"city\":12}";
  5. Person person = mapper.readValue(json, Person.class);
  6. System.out.println(person);
  7. }

输出为 Person{name='adai', age=21, map={color=red, city=12}}

可以看出,使用@JsonAnySetter注解,在json串中多余的属性会被自动放在map属性中,而不会抛出UnrecognizedPropertyException异常

注意:如果是Map<String,String> 那么即使是 {"name":"adai","age":21,"city":12,"weather":true}中的city对应数值 12 和weather对应布尔 true也会被封装进Map<String, String>中,但是Map<String, Integer> 无法封装String或其他类型,只能封装Integer

3 jackson 处理泛型转换

Java中 List和Map主要和泛型打交道,我们重点以这两个为例子,来学习jackson中如何在反序列中保留泛型信息的。

3.1 思考下面程序

  1. public class Student {
  2. private String name;
  3. private Integer age;
  4. //省略getter setter
  5. }
  1. @Test
  2. public void test3() throws Exception {
  3. ObjectMapper mapper = new ObjectMapper();
  4. List<Student> list = new ArrayList<>();
  5. list.add(new Student("adai",21));
  6. list.add(new Student("apei",22));
  7. String json = mapper.writeValueAsString(list);
  8. List<Student> student = mapper.readValue(json, List.class);
  9. System.out.println(student.get(0).getName());
  10. }

该程序在编译期不会报错,可以执行。那么在运行期的时候可以通过吗?

答案是:否定的。 即程序运行失败

  1. java.lang.ClassCastException: java.util.LinkedHashMap cannot be cast to com.antiy.common.adai.demo.Student

原因①:因为在反序列化的时候,mapper.readValue(json, List.class)并没有告诉jackson,这个json数据可以封装成Student对象,所以jackson默认将[{"name":"adai","age":21},{"name":"apei","age":22}]封装成两个LinkedHashMap对象,然后放入到List集合中。

原因②:既然我们知道了List中保存的对象在运行期是LinkedHashMap,那么为什么在代码中还可以student.get(0).getName(),这就跟Java编译期的泛型擦除有关系了,我们可以看下反编译后的代码

  1. List<Student> student = (List)mapper.readValue(json, List.class);
  2. System.out.println(((Student)student.get(0)).getName());

student.get(0)实际上的对象是LinkedHashMap,然后强转成Student,自然就报错了!

3.1 JavaType

我们可以使用JavaType来保存泛型信息

List:

  1. @Test
  2. public void test4() throws Exception {
  3. ObjectMapper mapper = new ObjectMapper();
  4. JavaType javaType = mapper.getTypeFactory().constructParametricType(List.class, Student.class);
  5. List<Student> list = new ArrayList<>();
  6. list.add(new Student("adai",21));
  7. list.add(new Student("apei",22));
  8. String json = mapper.writeValueAsString(list);
  9. List<Student> student2 = mapper.readValue(json, javaType);
  10. System.out.println(student2.get(0).getName());
  11. }

输出为 adai

Map:

  1. @Test
  2. public void test5() throws Exception {
  3. ObjectMapper mapper = new ObjectMapper();
  4. JavaType javaType = mapper.getTypeFactory().constructParametricType(Map.class, String.class, Student.class); // 第二个参数是Map的key,第三个参数是Map的value
  5. Map<String, Student> map = new HashMap<>();
  6. map.put("first",new Student("adai",21));
  7. map.put("second",new Student("apei",22));
  8. String json = mapper.writeValueAsString(map);
  9. Map<String, Student> result = mapper.readValue(json, javaType);
  10. System.out.println(result.get("first").getName());
  11. }

输出为 adai

3.2 TypeReference

TypeReferencejavaType模式更加方便,代码也更加简洁

List:

  1. @Test
  2. public void test6() throws Exception {
  3. ObjectMapper mapper = new ObjectMapper();
  4. List<Student> list = new ArrayList<>();
  5. list.add(new Student("adai",21));
  6. list.add(new Student("apei",22));
  7. String json = mapper.writeValueAsString(list);
  8. List<Student> student2 = mapper.readValue(json, new TypeReference<List<Student>>(){});
  9. System.out.println(student2.get(0).getName());
  10. }

输出为 adai

Map:

  1. @Test
  2. public void test7() throws Exception {
  3. ObjectMapper mapper = new ObjectMapper();
  4. Map<String, Student> map = new HashMap<>();
  5. map.put("first",new Student("adai",21));
  6. map.put("second",new Student("apei",22));
  7. String json = mapper.writeValueAsString(map);
  8. Map<String, Student> result = mapper.readValue(json, new TypeReference<Map<String,Student>>(){});
  9. System.out.println(result.get("first").getName());
  10. }

输出为 adai

可以看到,使用TypeReference,只需要在mapper.readValue后面增加一个 new TypeReference匿名内部类,写上自己想要封装的泛型对象,比javaType少了一行mapper.getTypeFactory().constructParametricType声明

4 jackson 自定义序列化和反序列化规则

jackson可以通过SerializationFeatureDeserializationFeature来自定义,序列化和反序列化规则,这也是jackson非常强大的地方。

4.1 enable disable configure

请看下面一个例子:

  1. mapper.configure(SerializationFeature.INDENT_OUTPUT,true);
  2. mapper.enable(SerializationFeature.INDENT_OUTPUT);
  3. mapper.disable(SerializationFeature.INDENT_OUTPUT);

这里有三个方法,configure方法接受配置名和要设置的值,Jackson 2.5版本新加的enable和disable方法则直接启用和禁用相应属性,我推荐使用后面两个方法。

4.2 SerializationFeature.INDENT_OUTPUT

默认为false,该属性主要是美化json输出

普通序列化的json串:

  1. {"name":"adai","age":21}

开启该属性后的json串:

  1. {
  2. "name" : "adai",
  3. "age" : 21
  4. }

4.3 SerializationFeature.FAIL_ON_EMPTY_BEANS

默认为true,该属性的意思是,如果一个对象中没有任何的属性,那么在序列化的时候就会报错

  1. public class Teacher {}
  1. @Test
  2. public void test1() throws Exception {
  3. ObjectMapper mapper = new ObjectMapper();
  4. Teacher teacher = new Teacher();
  5. System.out.println(mapper.writeValueAsString(teacher));
  6. }

程序运行将会报错:

com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class com.antiy.common.adai.entity.Teacher and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS)

当我们进行设置: mapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS)

输出为 {}

4.4 SerializationFeature.WRITE_DATES_AS_TIMESTAMPS

默认为true,该属性的意思是,jackson默认会将Date类型的数据序列化成时间戳

详情可以参考 2.5 @JsonFormat

4.5 DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES

默认为true,该属性的意思是,在反序列的时候,如果json串中存在一些key,但是在POJO中没有,那么程序将会抛出异常

  1. @Test
  2. public void test2() throws Exception {
  3. ObjectMapper mapper = new ObjectMapper();
  4. Student student = new Student("adai",21);
  5. String json = "{\"name\":\"adai\",\"age222\":21}"; //Student中没有age222
  6. mapper.readValue(json,Student.class);
  7. }

程序将会报错:UnrecognizedPropertyException: Unrecognized field "age222"

此时我们将FAIL_ON_UNKNOWN_PROPERTIES设置为false

  1. public void test2() throws Exception {
  2. ObjectMapper mapper = new ObjectMapper();
  3. mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
  4. Student student = new Student("adai",21);
  5. String json = "{\"name\":\"adai\",\"age222\":21}";
  6. System.out.println(mapper.readValue(json, Student.class));
  7. }

输出为 Student(name=adai, age=null)

4.6 DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT

该值默认为false,该属性的意思是,允许JSON空字符串值(“”)作为null绑定到POJO的属性上,看代码可能比较好理解一点。

  1. public class Teacher {
  2. private Student student;
  3. // 省略 getter setter constructor
  4. }
  1. @Test
  2. public void test2() throws Exception {
  3. ObjectMapper mapper = new ObjectMapper();
  4. String json = "{\"student\":\"\"}";
  5. System.out.println(mapper.readValue(json, Teacher.class));
  6. }

程序将会报错,MismatchedInputException,因为json串中key值student对应的value为 ""

此时我们可以设置DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT为true

输出为 Teacher(student=null)

"" 空串 被转换成null值 封装到Teacher对象的student属性中

4.7 SerializationFeature.WRAP_ROOT_VALUE

默认为false,该属性的意思是,将内容包裹为一个JSON属性,属性名由@JsonRootName注解指定。

详情请见 2.4 @JsonTypeName和@JsonTypeInfo

5 踩坑心得

5.1 TypeReference

一定要导入正确的TypeReference

5.2 DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT

注意,该属性只接受POJO的 “” 空字符串转换成 null,在json中,String非常特殊。

请先看4.6章节的内容。

此时我将Teacher中的student类型,换成String

  1. public class Teacher {
  2. private String student;
  3. }
  1. @Test
  2. public void test2() throws Exception {
  3. ObjectMapper mapper = new ObjectMapper();
  4. String json = "{\"student\":\"\"}";
  5. System.out.println(mapper.readValue(json, Teacher.class));
  6. }

输出为 Teacher(student=)

原来以为,如果是String属性,那么""也会转换成null,结果恰恰相反,只有POJO对象,“”才会转换成null

参考 stackoverflow:https://stackoverflow.com/questions/22688713/jackson-objectmapper-deserializationconfig-feature-accept-empty-string-as-null-o

6 感悟

6.1 以Json的角度理解Map和List

在对象序列化和反序列化的过程中,自己对Map和List又有了新的理解。

Map可以当做是一个任意对象,保存字段属性。

在 3.1中,如果jackson不知道反序列化的对象,那么jackson将会以LinkedHashMap来进行处理,这正是因为Map的 Key-Value 特性。

  1. @Test
  2. public void test2() throws Exception {
  3. ObjectMapper mapper = new ObjectMapper();
  4. Map<String, Object> map = new HashMap<>(2);
  5. map.put("name","adai");
  6. map.put("age",21);
  7. System.out.println("map序列化: " + mapper.writeValueAsString(map));
  8. Student student = new Student("adai",21);
  9. System.out.println("student序列化: " + mapper.writeValueAsString(student));
  10. }

输出为 map序列化: {"name":"adai","age":21}

student序列化: {"name":"adai","age":21}

可以看到Map和Student序列化的结果都是一样的,那么在反序列化的时候,可以用Student对象接受的数据,自然而然也可以用Map接收,这就是为什么在关于泛型反序列化的时候,如果jackson不知道具体的对象,全部都会用LinkHashMap接收

List就当做是一个数组

参考资料:

https://blog.csdn.net/u011054333/article/details/80504154#commentBox
https://www.ibm.com/developerworks/cn/java/jackson-advanced-application/index.html

作者:一杯热咖啡AAA

出处:https://www.cnblogs.com/AdaiCoffee/

本文以学习、研究和分享为主,欢迎转载。如果文中有不妥或者错误的地方还望指出,以免误人子弟。如果你有更好的想法和意见,可以留言讨论,谢谢!

终极CRUD-3-用Jackson解析json的更多相关文章

  1. JackSon解析json字符串

    JackSon解析json字符串 原文:http://blog.csdn.net/java_huashan/article/details/9353903 概述 jackson解析json例子 准备工 ...

  2. 记一次FastJSON和Jackson解析json时遇到的中括号问题

    版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/jadyer/article/details/24395015 完整版见https://jadyer. ...

  3. 使用 jackson 解析 json 演示样例

    首先须要下载3个包,下载地址在Github FasterXML,这三个核心模块各自是: Streaming ("jackson-core") defines low-level s ...

  4. Jackson 解析json数据之忽略解析字段注解@JsonIgnoreProperties

    转自:http://blog.csdn.net/ngl272/article/details/70217104 以前解析json用的惯的就是Google的gson了,用惯了基本就用它了,一直也没发现什 ...

  5. [转]Jackson 解析json数据之忽略解析字段注解@JsonIgnoreProperties

    以前解析json用的惯的就是Google的gson了,用惯了基本就用它了,一直也没发现什么大问题,因为都是解析简单的json数据.但是最近学习springboot,要解析一个比较复杂的json数据.就 ...

  6. Jackson 解析 JSON 详细教程

    点赞再看,动力无限. 微信搜「程序猿阿朗 」. 本文 Github.com/niumoo/JavaNotes 和 未读代码博客 已经收录,有很多知识点和系列文章. JSON 对于开发者并不陌生,如今的 ...

  7. 使用Jackson解析Json示例

    原文http://blog.csdn.net/gebitan505/article/details/17005735 custom.json: {     "country":&q ...

  8. 使用jackson解析JSON数据

    本文介绍使用jackson来对json数据进行解析操作 首先,需要去官网下载jackson,本文使用的是(jackson-all-1.9.11.jar) 主要通过ObjectMapper对json进行 ...

  9. 使用jackson解析json串得到树模型,然后遍历树模型获得需要的数据

    Problem:从网址 http://quotes.money.163.com/hs/service/marketradar_ajax.php?host=http%3A%2F%2Fquotes.mon ...

  10. jackson 解析json问题

    1.json串中有key为A,但指定转换的mybean中未定义属性A,会抛异常.处理:mapper.configure(Feature.FAIL_ON_UNKNOWN_PROPERTIES, fals ...

随机推荐

  1. springMVC中接收数组参数

    方式一. 后台:public ResultBean queryItemRulesByItemIds(int userId, int[] itemIds) 方式二.

  2. 基础_String

    String str1="hello"; String str2="hello"; String str3="hello"; String ...

  3. Effictive C++ 学习记录

    这是前段时间看的书,整理到这里吧,以后查看也方便. 这些条款需要反复查看. 条款01:视C++为一个语言联邦 条款02:尽量用const.enum.inline替换#define 条款03:尽可能的使 ...

  4. STL学习笔记8 -- 函数对象

    重载函数调用操作符的类,其对象常称为函数对象(function object),即它们是行为类似函数的对象.一个类对象,表现出一个函数的特征,就是通过“对象名+(参数列表)”的方式使用一个类对象,如果 ...

  5. MongoDB快速入门学习笔记8 MongoDB的java驱动操作

    import java.util.ArrayList; import java.util.List; import java.util.regex.Pattern; import org.bson.D ...

  6. Python学习-day11 RabbitMQ Redis

    这次文章包含两个内容: 1.RabbitMQ使用 2.Redis基础操作 代码部分为练习笔记和作业 概念部分转自Alex老师 RabbitMQ 安装 http://www.rabbitmq.com/i ...

  7. svm常用核函数

    SVM核函数的选择对于其性能的表现有至关重要的作用,尤其是针对那些线性不可分的数据,因此核函数的选择在SVM算法中就显得至关重要.对于核技巧我们知道,其目的是希望通过将输入空间内线性不可分的数据映射到 ...

  8. 基础概念:Oracle数据库

    基础概念:Oracle数据库.实例.用户.表空间.表之间的关系 数据库:Oracle数据库是数据的物理存储.这就包括(数据文件ORA或者DBF.控制文件.联机日志.参数文件).其实Oracle数据库的 ...

  9. 【bzoj1531】[POI2005]Bank notes 多重背包dp

    题目描述 Byteotian Bit Bank (BBB) 拥有一套先进的货币系统,这个系统一共有n种面值的硬币,面值分别为b1, b2,..., bn. 但是每种硬币有数量限制,现在我们想要凑出面值 ...

  10. leetcode 27 水

    class Solution { public: int removeElement(vector<int>& nums, int val) { int length=nums.s ...