当前位置: 首页>>代码示例>>Java>>正文


Java GsonBuilder.excludeFieldsWithoutExposeAnnotation方法代码示例

本文整理汇总了Java中com.google.gson.GsonBuilder.excludeFieldsWithoutExposeAnnotation方法的典型用法代码示例。如果您正苦于以下问题:Java GsonBuilder.excludeFieldsWithoutExposeAnnotation方法的具体用法?Java GsonBuilder.excludeFieldsWithoutExposeAnnotation怎么用?Java GsonBuilder.excludeFieldsWithoutExposeAnnotation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.gson.GsonBuilder的用法示例。


在下文中一共展示了GsonBuilder.excludeFieldsWithoutExposeAnnotation方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: deserialize

import com.google.gson.GsonBuilder; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void deserialize(String jsonString) {
    Type listType = new TypeToken<ArrayList<Logo>>() {
    }.getType();

    final GsonBuilder builder = new GsonBuilder();
    builder.excludeFieldsWithoutExposeAnnotation();
    final Gson gson = builder.create();

    List<Logo> list = gson.fromJson(jsonString, listType);
    for (int i = 0; i < list.size(); i++) {
        list.get(i).setNid(i + 1);
    }
    this.addAll(list);
}
 
开发者ID:NoraUi,项目名称:NoraUi,代码行数:19,代码来源:Logos.java

示例2: listKeyMaps

import com.google.gson.GsonBuilder; //导入方法依赖的package包/类
/**
 * 将json转化为List<Map<String, Object>>
 * @param jsonString
 * @return
 */
public static List<Map<String, Object>> listKeyMaps(String jsonString) {
    List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
    try {
        GsonBuilder builder = new GsonBuilder();
        // 不转换没有 @Expose 注解的字段
        builder.excludeFieldsWithoutExposeAnnotation();
        Gson gson = builder.create();
        list = gson.fromJson(jsonString,
                new TypeToken<List<Map<String, Object>>>() {
                }.getType());
    } catch (Exception e) {
        e.printStackTrace();
    }
    return list;
}
 
开发者ID:Liuzhiyang94,项目名称:ComponentProjectDemo,代码行数:21,代码来源:JsonUtils.java

示例3: deserialize

import com.google.gson.GsonBuilder; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void deserialize(String jsonString) {
    Type listType = new TypeToken<ArrayList<Article>>() {
    }.getType();

    final GsonBuilder builder = new GsonBuilder();
    builder.excludeFieldsWithoutExposeAnnotation();
    final Gson gson = builder.create();

    List<Article> list = gson.fromJson(jsonString, listType);
    this.addAll(list);
}
 
开发者ID:NoraUi,项目名称:NoraUi,代码行数:16,代码来源:Articles.java

示例4: deserialize

import com.google.gson.GsonBuilder; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void deserialize(String jsonString) {
    final GsonBuilder builder = new GsonBuilder();
    builder.excludeFieldsWithoutExposeAnnotation();
    final Gson gson = builder.create();
    Article w = gson.fromJson(jsonString, Article.class);
    this.nid = w.nid;
    this.title = w.title;
    this.text = w.text;
    this.author = w.author;
    this.note = w.note;
}
 
开发者ID:NoraUi,项目名称:NoraUi,代码行数:16,代码来源:Article.java

示例5: serialize

import com.google.gson.GsonBuilder; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public String serialize() {
    final GsonBuilder builder = new GsonBuilder();
    builder.excludeFieldsWithoutExposeAnnotation();
    builder.disableHtmlEscaping();
    final Gson gson = builder.create();
    return gson.toJson(this);
}
 
开发者ID:NoraUi,项目名称:NoraUi,代码行数:12,代码来源:DemoModel.java

示例6: deserialize

import com.google.gson.GsonBuilder; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void deserialize(String jsonString) {
    final GsonBuilder builder = new GsonBuilder();
    builder.excludeFieldsWithoutExposeAnnotation();
    final Gson gson = builder.create();
    Logo w = gson.fromJson(jsonString, Logo.class);
    this.nid = w.nid;
    this.brand = w.brand;
}
 
开发者ID:NoraUi,项目名称:NoraUi,代码行数:13,代码来源:Logo.java

示例7: getHomebrewGson

import com.google.gson.GsonBuilder; //导入方法依赖的package包/类
/**
 * Returns a GSON instance with our converters applied.
 *
 * @return a GSON instance with our converters applied
 */
private static Gson getHomebrewGson() {
    GsonBuilder gsonBuilder = new GsonBuilder();
    gsonBuilder.excludeFieldsWithoutExposeAnnotation();
    gsonBuilder.registerTypeHierarchyAdapter(LocalDateTime.class, new LocalDateTimeSerializer());
    return gsonBuilder.create();
}
 
开发者ID:teiler,项目名称:api.teiler.io,代码行数:12,代码来源:HomebrewGson.java

示例8: json2Object

import com.google.gson.GsonBuilder; //导入方法依赖的package包/类
/**
 * 将json转化为cls对象
 * @param jsonString json字符串
 * @param cls 对应的类
 * @return
 */
public static <T> T json2Object(String jsonString, Class<T> cls) {
    T t = null;
    try {
        GsonBuilder builder = new GsonBuilder();
        // 不转换没有 @Expose 注解的字段
        builder.excludeFieldsWithoutExposeAnnotation();
        Gson gson = builder.create();
        t = gson.fromJson(jsonString, cls);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return t;
}
 
开发者ID:Liuzhiyang94,项目名称:ComponentProjectDemo,代码行数:20,代码来源:JsonUtils.java

示例9: deserialize

import com.google.gson.GsonBuilder; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void deserialize(String jsonString) {
    Type listType = new TypeToken<ArrayList<Customer>>() {
    }.getType();

    final GsonBuilder builder = new GsonBuilder();
    builder.excludeFieldsWithoutExposeAnnotation();
    final Gson gson = builder.create();

    List<Customer> list = gson.fromJson(jsonString, listType);
    this.addAll(list);
}
 
开发者ID:NoraUi,项目名称:noraui-academy,代码行数:16,代码来源:Customers.java

示例10: deserialize

import com.google.gson.GsonBuilder; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void deserialize(String jsonString) {
    final GsonBuilder builder = new GsonBuilder();
    builder.excludeFieldsWithoutExposeAnnotation();
    final Gson gson = builder.create();
    Customer w = gson.fromJson(jsonString, Customer.class);
    this.wid = w.wid;
    this.lastNameCustomer = w.lastNameCustomer;
    this.firstNameCustomer = w.firstNameCustomer;
}
 
开发者ID:NoraUi,项目名称:noraui-academy,代码行数:14,代码来源:Customer.java

示例11: getGson

import com.google.gson.GsonBuilder; //导入方法依赖的package包/类
@Provides
@Nonnull
public Gson getGson(@Nonnull Injector injector) {
    GsonBuilder builder = new GsonBuilder();
    addTypeAdapters(builder, injector);
    builder.setPrettyPrinting();
    builder.excludeFieldsWithoutExposeAnnotation();
    return builder.create();
}
 
开发者ID:VoxelGamesLib,项目名称:VoxelGamesLibv2,代码行数:10,代码来源:VoxelGamesLibModule.java

示例12: FileManager

import com.google.gson.GsonBuilder; //导入方法依赖的package包/类
private FileManager() {
    GsonBuilder gsonBuilder = new GsonBuilder();
    gsonBuilder.excludeFieldsWithoutExposeAnnotation();
    gson = gsonBuilder.create();
}
 
开发者ID:GRnice,项目名称:PandwarfDefenderProject,代码行数:6,代码来源:FileManager.java


注:本文中的com.google.gson.GsonBuilder.excludeFieldsWithoutExposeAnnotation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。