热门面试题与答案和在线测试
面向面试准备、在线测试、教程与实战练习的学习平台

通过聚焦学习路径、模拟测试和面试实战内容持续提升技能。

WithoutBook 将分主题面试题、在线练习测试、教程和对比指南整合到一个响应式学习空间中。

面试准备
首页 / 面试主题 / Google Gson
WithoutBook LIVE 模拟面试 Google Gson 相关面试主题: 39

面试题与答案

了解热门 Google Gson 面试题与答案,帮助应届生和有经验的候选人为求职面试做好准备。

共 8 道题 面试题与答案

面试前建议观看的最佳 LIVE 模拟面试

了解热门 Google Gson 面试题与答案,帮助应届生和有经验的候选人为求职面试做好准备。

面试题与答案

搜索问题以查看答案。

应届生 / 初级级别面试题与答案

问题 1

What is Google-Gson?

Google Gson is a Java library that can be used to convert Java Objects into respective JSON format. In another way, it can used to convert the JSON into equivalent java objects. There are some other java libraries also capable of doing this conversion, but Gson stands among very few which do not require any pre-annotated java classes OR sourcecode of java classes in any way.
Gson also support the old java classes which had not support of generics in them for type information. It just work with these legacy classes smoothly.
保存以便复习

保存以便复习

收藏此条目、标记为困难题,或将其加入复习集合。

打开我的学习资料库
这有帮助吗?
添加评论 查看评论
问题 2

What are the two ways to create Gson objects?

Gson object can be created in two ways. First way gives you a quick Gson object ready for faster coding, while second way uses GsonBuilder to build a more sophisticated Gson object.

//First way to create a Gson object for faster coding
Gson gson = new Gson();

//Second way to create a Gson object using GsonBuilder
Gson gson = new GsonBuilder()
.disableHtmlEscaping()
.setFieldNamingPolicy(FieldNamingPolicy.UPPER_CAMEL_CASE)
.setPrettyPrinting()
.serializeNulls()
.create();

 

When using GsonBuilder, there are plenty of other useful options you can provide to Gson object.

保存以便复习

保存以便复习

收藏此条目、标记为困难题,或将其加入复习集合。

打开我的学习资料库
这有帮助吗?
添加评论 查看评论
问题 3

How to convert Java objects to JSON format?

To convert the java objects to JSON format, use toJson() method.

Employee employee = new Employee();
employee.setId(1);
employee.setFirstName("Arindam");
employee.setLastName("Ghosh");
employee.setRoles(Arrays.asList("FINANCE", "MANAGER"));

Gson gson = new Gson();
System.out.println(gson.toJson(employee));

Output:

{

    "id":1,

    "firstName":"Rob",

    "lastName":"Bosch",

    "roles":["FIINANCE","MANAGER"]

}

保存以便复习

保存以便复习

收藏此条目、标记为困难题,或将其加入复习集合。

打开我的学习资料库
这有帮助吗?
添加评论 查看评论
问题 4

How to convert JSON to Java Objects?

To convert the JSON to java object, use fromJson() method.

Gson gson = new Gson();
System.out.println(
    gson.fromJson("{'id':1,'firstName':'Arindam','lastName':'Ghosh','roles':['FINANCE','MANAGER']}", 
    Employee.class));
     
Output:
Employee [id=1, firstName=Arindam, lastName=Ghosh, roles=[FINANCE, MANAGER]]

保存以便复习

保存以便复习

收藏此条目、标记为困难题,或将其加入复习集合。

打开我的学习资料库
这有帮助吗?
添加评论 查看评论

用户评价最有帮助的内容:

版权所有 © 2026,WithoutBook。