List of usage examples for com.google.gson GsonBuilder serializeNulls
boolean serializeNulls
To view the source code for com.google.gson GsonBuilder serializeNulls.
Click Source Link
From source file:org.primefaces.extensions.converter.TimelineEventsConverter.java
License:Apache License
@Override public Object getAsObject(FacesContext context, UIComponent component, String value) { // register a time zone aware date adapter GsonBuilder gsonBilder = new GsonBuilder(); gsonBilder.registerTypeAdapter(Date.class, new DateTypeAdapter()); gsonBilder.serializeNulls(); return gsonBilder.create().fromJson(value, getObjectType(TYPE_FOR_EVENTS, false)); }
From source file:org.primefaces.extensions.converter.TimelineEventsConverter.java
License:Apache License
@Override public String getAsString(FacesContext context, UIComponent component, Object value) { // register a time zone aware date adapter GsonBuilder gsonBilder = new GsonBuilder(); gsonBilder.registerTypeAdapter(Date.class, new DateTypeAdapter()); gsonBilder.serializeNulls(); return gsonBilder.create().toJson(value, getObjectType(TYPE_FOR_EVENTS, false)); }
From source file:org.primefaces.extensions.util.GsonConverter.java
License:Apache License
private GsonConverter() { GsonBuilder gsonBilder = new GsonBuilder(); gsonBilder.serializeNulls(); gson = gsonBilder.create(); }
From source file:org.primefaces.extensions.util.json.GsonConverter.java
License:Apache License
private GsonConverter() { GsonBuilder gsonBilder = new GsonBuilder(); gsonBilder.registerTypeAdapter(Date.class, new DateTypeAdapter()); gsonBilder.serializeNulls(); gson = gsonBilder.create();//w w w . j a v a 2s.co m }
From source file:org.primefaces.extensions.util.json.GsonExposeAwareConverter.java
License:Apache License
private GsonExposeAwareConverter() { GsonBuilder gsonBilder = new GsonBuilder(); gsonBilder.registerTypeAdapter(Date.class, new DateTypeAdapter()); gsonBilder.serializeNulls(); gsonBilder.excludeFieldsWithoutExposeAnnotation(); gson = gsonBilder.create();//w w w .j a v a2 s.c om }
From source file:org.restcomm.connect.http.IncomingPhoneNumbersEndpoint.java
License:Open Source License
@PostConstruct public void init() throws ObjectInstantiationException { final DaoManager storage = (DaoManager) context.getAttribute(DaoManager.class.getName()); configuration = (Configuration) context.getAttribute(Configuration.class.getName()); super.init(configuration.subset("runtime-settings")); dao = storage.getIncomingPhoneNumbersDao(); accountsDao = storage.getAccountsDao(); /*//from w w w. ja v a 2s. c o m phoneNumberProvisioningManager = (PhoneNumberProvisioningManager) context.getAttribute("PhoneNumberProvisioningManager"); if(phoneNumberProvisioningManager == null) { final String phoneNumberProvisioningManagerClass = configuration.getString("phone-number-provisioning[@class]"); Configuration phoneNumberProvisioningConfiguration = configuration.subset("phone-number-provisioning"); Configuration telestaxProxyConfiguration = configuration.subset("runtime-settings").subset("telestax-proxy"); phoneNumberProvisioningManager = (PhoneNumberProvisioningManager) new ObjectFactory(getClass().getClassLoader()) .getObjectInstance(phoneNumberProvisioningManagerClass); ContainerConfiguration containerConfiguration = new ContainerConfiguration(getOutboundInterfaces()); phoneNumberProvisioningManager.init(phoneNumberProvisioningConfiguration, telestaxProxyConfiguration, containerConfiguration); context.setAttribute("phoneNumberProvisioningManager", phoneNumberProvisioningManager); } */ // get manager from context or create it if it does not exist phoneNumberProvisioningManager = new PhoneNumberProvisioningManagerProvider(configuration, context).get(); Configuration callbackUrlsConfiguration = configuration.subset("phone-number-provisioning") .subset("callback-urls"); phoneNumberParameters = new PhoneNumberParameters(callbackUrlsConfiguration.getString("voice[@url]"), callbackUrlsConfiguration.getString("voice[@method]"), false, callbackUrlsConfiguration.getString("sms[@url]"), callbackUrlsConfiguration.getString("sms[@method]"), callbackUrlsConfiguration.getString("fax[@url]"), callbackUrlsConfiguration.getString("fax[@method]"), callbackUrlsConfiguration.getString("ussd[@url]"), callbackUrlsConfiguration.getString("ussd[@method]")); final IncomingPhoneNumberConverter converter = new IncomingPhoneNumberConverter(configuration); listConverter = new IncomingPhoneNumberListConverter(configuration); final GsonBuilder builder = new GsonBuilder(); builder.serializeNulls(); builder.registerTypeAdapter(IncomingPhoneNumber.class, converter); builder.registerTypeAdapter(IncomingPhoneNumberList.class, listConverter); builder.setPrettyPrinting(); gson = builder.create(); xstream = new XStream(); xstream.alias("RestcommResponse", RestCommResponse.class); xstream.registerConverter(converter); xstream.registerConverter(listConverter); xstream.registerConverter(new AvailableCountriesConverter(configuration)); xstream.registerConverter(new RestCommResponseConverter(configuration)); }
From source file:org.restcomm.connect.http.OrganizationsEndpoint.java
License:Open Source License
private void registerConverters() { final OrganizationConverter converter = new OrganizationConverter(configuration); listConverter = new OrganizationListConverter(configuration); final ClientConverter clientConverter = new ClientConverter(configuration); final ClientListConverter clientListConverter = new ClientListConverter(configuration); final GsonBuilder builder = new GsonBuilder(); builder.serializeNulls(); builder.registerTypeAdapter(Organization.class, converter); builder.registerTypeAdapter(Client.class, converter); builder.setPrettyPrinting();/*w ww. ja v a 2 s . c om*/ gson = builder.create(); xstream = new XStream(); xstream.alias("RestcommResponse", RestCommResponse.class); xstream.registerConverter(converter); xstream.registerConverter(listConverter); xstream.registerConverter(clientConverter); xstream.registerConverter(clientListConverter); xstream.registerConverter(new RestCommResponseConverter(configuration)); }
From source file:org.sonatype.nexus.extdirect.internal.ExtDirectGsonBuilderConfigurator.java
License:Open Source License
@Override public void configure(final GsonBuilder builder, final GlobalConfiguration configuration) { if (configuration.getDebug()) { builder.setPrettyPrinting();//from w ww .java 2s . c o m } builder.serializeNulls(); builder.disableHtmlEscaping(); builder.setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX"); }
From source file:org.springframework.http.converter.json.GsonFactoryBean.java
License:Apache License
@Override public void afterPropertiesSet() { GsonBuilder builder = (this.base64EncodeByteArrays ? GsonBuilderUtils.gsonBuilderWithBase64EncodedByteArrays() : new GsonBuilder()); if (this.serializeNulls) { builder.serializeNulls(); }// w w w. jav a2s . c o m if (this.prettyPrinting) { builder.setPrettyPrinting(); } if (this.disableHtmlEscaping) { builder.disableHtmlEscaping(); } if (this.dateFormatPattern != null) { builder.setDateFormat(this.dateFormatPattern); } this.gson = builder.create(); }
From source file:org.sweble.wikitext.example.Serializer.java
License:Apache License
private Gson getJsonSerializer() { final AstNodeJsonTypeAdapter<WtNode> nodeConverter = AstNodeJsonTypeAdapter.forNodeType(WtNode.class); EngineAstNodeConverter.setup(new WikiConfigImpl(), nodeConverter); // As long as GSON does not handle Object collections and polymorphism // correctly, the "warnings" attribute cannot be serialized nodeConverter.suppressProperty("warnings"); nodeConverter.setNodeFactory(new NodeFactory<WtNode>() { NodeFactory<WtNode> nf = nodeConverter.getNodeFactory(); @Override//from www .ja va2 s .c o m public WtNode instantiateNode(Class<?> clazz) { return nf.instantiateNode(clazz); } @Override public WtNode instantiateDefaultChild(NamedMemberId id, Class<?> childType) { return nf.instantiateDefaultChild(id, childType); } @Override public Object instantiateDefaultProperty(NamedMemberId id, Class<?> type) { if (id.memberName == "warnings") return Collections.EMPTY_LIST; return nf.instantiateDefaultProperty(id, type); } }); AstRtDataJsonTypeAdapter<WtRtData> rtdConverter = new AstRtDataJsonTypeAdapter<WtRtData>(WtRtData.class); EngineAstNodeConverter.setup(rtdConverter); GsonBuilder builder = new GsonBuilder(); builder.registerTypeHierarchyAdapter(RtData.class, rtdConverter); builder.registerTypeHierarchyAdapter(AstNode.class, nodeConverter); builder.serializeNulls(); builder.setPrettyPrinting(); return builder.create(); }