當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。