public class JsonBuilder
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
build() |
static JsonBuilder |
json()
Creates new instance of this builder.
|
JsonBuilder |
withCode(java.lang.String code)
Specifies field named "code" for the JSON output.
|
JsonBuilder |
withField(java.lang.String field,
java.util.Collection<?> values)
Specifies field value for the JSON output.
|
JsonBuilder |
withField(java.lang.String field,
JsonBuilder builder)
Specifies field value for the JSON output.
|
JsonBuilder |
withField(java.lang.String field,
java.lang.Number number)
Specifies field value for the JSON output.
|
JsonBuilder |
withField(java.lang.String field,
java.lang.String value)
Specifies field value for the JSON output.
|
JsonBuilder |
withFieldValues(java.lang.String field,
java.lang.Object... values)
Specifies field value for the JSON output.
|
JsonBuilder |
withId(java.lang.String id)
Specifies field named "id" for the JSON output.
|
JsonBuilder |
withLocalizedAttributes(java.util.Map<java.lang.String,java.lang.String>... attributes)
Specifies the localized attributes for the JSON output.
|
public static JsonBuilder json()
"{}" JSON when built.public JsonBuilder withCode(java.lang.String code)
withField("code", code)code - value for the "code" fieldpublic JsonBuilder withId(java.lang.String id)
withField("id", code)id - value for the "id" fieldpublic JsonBuilder withField(java.lang.String field, JsonBuilder builder)
field - name of the JSON field, which prints before the ":" separator. For example, address in {"address": {...}}builder - nested JSON object to be used as value for the fieldpublic JsonBuilder withField(java.lang.String field, java.lang.Number number)
field - name of the JSON field, which prints before the ":" separator. For example, address in {"address": {...}}number - numeric value for the fieldpublic JsonBuilder withFieldValues(java.lang.String field, java.lang.Object... values)
field - name of the JSON field, which prints before the ":" separator. For example, reviews in {"reviews": [...]}values - a collection of values for the fieldpublic JsonBuilder withField(java.lang.String field, java.util.Collection<?> values)
field - name of the JSON field, which prints before the ":" separator. For example, reviews in {"reviews": [...]}values - nested JSON objects to be used as a collection value for the fieldpublic JsonBuilder withField(java.lang.String field, java.lang.String value)
field - name of the JSON field, which prints before the ":" separator. For example, country in {"country": "USA"}value - value of the JSON field, which prints after the ":" separator. For example, USA in {"country": "USA"}public JsonBuilder withLocalizedAttributes(java.util.Map<java.lang.String,java.lang.String>... attributes)
attributes - An array of Maps with the name of the localized attribute as the key, and the localized value as the valuepublic java.lang.String build()
Copyright © 2018 SAP SE. All Rights Reserved.