Code example for GsonBuilder

Methods: create

0
	public static<S> JsonElement mapToIndex(S s, BasePojoIndexMap<S> docMap) {
		GsonBuilder gb = BaseIndexPojo.getDefaultBuilder();
		if (null != docMap) {
			gb = docMap.extendBuilder(gb);
		} 
		return gb.create().toJsonTree(s);
	} 
	public static<S> S mapFromIndex(String s, Class<S> type, BasePojoIndexMap<S> docMap) {
		GsonBuilder gb = BaseIndexPojo.getDefaultBuilder();
		if (null != docMap) {
			gb = docMap.extendBuilder(gb);
		} 
		return gb.create().fromJson(s, type);
	} 
	@SuppressWarnings("unchecked") 
	public static<S> S mapFromIndex(String s, TypeToken<S> type, BasePojoIndexMap<S> docMap) {
		GsonBuilder gb = BaseIndexPojo.getDefaultBuilder();
		if (null != docMap) {
			gb = docMap.extendBuilder(gb);
		} 
Experience pair programming with AI  Get Codota for Java