uCosminexus Application Server, Web Service Development Guide
![[Contents]](FIGURE/CONTENT.GIF)
![[Glossary]](FIGURE/GLOSS.GIF)
![[Index]](FIGURE/INDEX.GIF)
![[Back]](FIGURE/FRONT.GIF)
You can specify the following data types for the POJO fields and Bean properties.
Table 18-2 Available data types for the POJO fields and Bean properties (POJO to JSON mapping)
| No. |
Data |
| 1 |
Primitive |
int |
| 2 |
short |
| 3 |
long |
| 4 |
float |
| 5 |
double |
| 6 |
char |
| 7 |
byte |
| 8 |
boolean |
| 9 |
Wrapper class |
Integer |
| 10 |
Short |
| 11 |
Long |
| 12 |
Float |
| 13 |
Double |
| 14 |
Character |
| 15 |
Byte |
| 16 |
Boolean |
| 17 |
java.lang.String |
| 18 |
java.math.BigInteger |
| 19 |
java.math.BigDecimal |
| 20 |
java.util.Date |
| 21 |
java.util.Calendar |
| 22 |
java.lang.Enum |
| 23 |
POJO#1 |
| 24 |
java.util.List<T>#2 |
| 25 |
java.util.Set<T>#2 |
| 26 |
java.util.Map<T,T>#2 |
| 27 |
An Array containing any item from No.1 through 26#2 |
- #1
- You can recursively have a POJO as a field or aBean property. For conditions of a supported POJO, see 18.2 POJO to JSON mapping.
- #2
- The type of T is any one item listed in No. 1 through 26 in the above table.
Notes:
- If a field or a Bean property is not initialized, the default value of the respective data types (the respective default value for the primitive types, null for object type) is mapped to the generated JSON.
- If the value of the types in No. 9 through 27 in the above table is null, null is mapped to the corresponding value of the generated JSON.
- If the value of the types in No.24 through 27 in the above table includes null, null is mapped to the corresponding value of the generated JSON.
- If the value of the types in No.20 or 21 in the table is other than null, the corresponding value of the generated JSON is mapped to a value same as the value expressed in milliseconds. For example, if you are using Date as a data type, the value acquired on calling the getTime() method of the Date class is mapped. If you are using the Calendar type, the value acquired on calling the getTime() method of the Date class is mapped to the Date object acquired on calling the getTime() method of the Calendar class.
- If the value of the type in No.26 in the above table is null, the JsonMappingException exception is thrown. For details on exception handling, see 18.3.3 Exception handling.
- If No. 27 of the table is the char array or byte array, the corresponding value of the generated JSON is mapped with the next respective value, and not with the array.
- The char array: character string generated from an array
- The byte array: Base64 encoded character string generated from an array
The following are the examples:
- The Bean property of char[] type having value {a,b} and name "bean" is mapped to {"bean":["ab"]} and not {"bean":["a","b"]}.
- The Bean property of byte[] type having value {1,2} and name "bean" is mapped to {"bean":["AQ=="]} and not {"bean":[1,2]}.
All Rights Reserved. Copyright (C) 2013, Hitachi, Ltd.