Class JsonBuilder
java.lang.Object
de.hybris.platform.integrationservices.util.JsonBuilder
A helper to build a string in JSON format.
-
Method Summary
Modifier and TypeMethodDescriptionbuild()static JsonBuilderjson()Creates new instance of this builder.Specifies field named "code" for the JSON output.Specifies field value for the JSON output.withField(String field, JsonBuilder builder) Specifies field value for the JSON output.Specifies a character field value for the JSON output.Specifies field value for the JSON output.Specifies field value for the JSON output.withField(String field, Collection<?> values) Specifies field value for the JSON output.Specifies date field value for the JSON output.withFieldValues(String field, Object... values) Specifies field value for the JSON output.Specifies field named "id" for the JSON output.final JsonBuilderwithLocalizedAttributes(Map<String, String>... attributes) Specifies the localized attributes for the JSON output.
-
Method Details
-
json
Creates new instance of this builder.- Returns:
- new builder instance, which has no fields specified and results in
"{}"JSON when built.
-
withCode
Specifies field named "code" for the JSON output. This is the same as callingwithField("code", code)- Parameters:
code- value for the "code" field- Returns:
- a builder with the field specified
-
withId
Specifies field named "id" for the JSON output. This is the same as callingwithField("id", code)- Parameters:
id- value for the "id" field- Returns:
- a builder with the field specified
-
withField
Specifies field value for the JSON output.- Parameters:
field- name of the JSON field, which prints before the ":" separator. For example,addressin{"address": {...}}builder- nested JSON object to be used as value for the field- Returns:
- a builder with the field specified.
-
withField
Specifies field value for the JSON output.- Parameters:
field- name of the JSON field, which prints before the ":" separator. For example,addressin{"address": {...}}number- numeric value for the field- Returns:
- a builder with the field specified.
-
withField
Specifies field value for the JSON output.- Parameters:
field- name of the JSON field, which prints before the ":" separator. For example,addressin{"address": {...}}value- boolean value for the field- Returns:
- a builder with the field specified.
-
withField
Specifies date field value for the JSON output.- Parameters:
field- name of the JSON field, which prints before the ":" separator. For example,addressin{"address": {...}}date- date value for the field- Returns:
- a builder with the field specified.
-
withFieldValues
Specifies field value for the JSON output.- Parameters:
field- name of the JSON field, which prints before the ":" separator. For example,reviewsin{"reviews": [...]}values- a collection of values for the field- Returns:
- a builder with the field specified.
-
withField
Specifies field value for the JSON output.- Parameters:
field- name of the JSON field, which prints before the ":" separator. For example,reviewsin{"reviews": [...]}values- nested JSON objects to be used as a collection value for the field- Returns:
- a builder with the field specified.
-
withField
Specifies a character field value for the JSON output.- Parameters:
field- name of the JSON field, which prints before the ":" separator. For example,countryin{"country": "USA"}value- value of the JSON field, which prints after the ":" separator. For example,'a'in{"char": "a"}- Returns:
- a builder with the field specified.
-
withField
Specifies field value for the JSON output.- Parameters:
field- name of the JSON field, which prints before the ":" separator. For example,countryin{"country": "USA"}value- value of the JSON field, which prints after the ":" separator. For example,USAin{"country": "USA"}- Returns:
- a builder with the field specified.
-
withLocalizedAttributes
Specifies the localized attributes for the JSON output.- Parameters:
attributes- An array ofMaps with the name of the localized attribute as the key, and the localized value as the value- Returns:
- a builder with the specified localized attributes.
-
build
-