Package org.teiid.spring.annotations
Annotation Type JsonTable
-
@Target(TYPE) @Retention(RUNTIME) public @interface JsonTable
Use this annotation on any Entity class, that defines the data from a JSON file or web resource.
For Example if you have a JSON payload like
You can parse and read the contents of this file into an entity by defining this annotation on a Entity class like[ { "id":1, "FirstName":"John", "LastName":"Doe", "Age":20 }, { "id":2, "FirstName":"Susan", "LastName":"Webber", "Age":55 }, { "id":1, "FirstName":"Mike", "LastName":"Smith", "Age":34 } ]
Note: the getters and setter are omitted for brevity.@Entity @JsonTable(source=file, endpoint="/path/to/file.txt" rootIsArray=true) public class Person { @Id private int id; @Column(name="FirstName") private String firstName; @Column(name="LastName") private String lastName; @Column(name="Age") private int age; ... }
For more information checkout XMLTABLE in Teiid.
-
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description booleanordinalOn Column ONLY, this defines the column as ordinal identity column.StringrootRoot of the document where the parsing needs to start from.booleanrootIsArrayJSON root content is array.StringsourceSource name; If overriding the org.teiid.translator.ws.WsExecutionFactory bean then provide the name of the bean
-
-
-
Element Detail
-
endpoint
String endpoint
On Class ONLY The endpoint where the document is located at. If this is file resource then this field can be used to define name of the file. If this is REST based call, it can either define the endpoint URL or can refer to a bean name that returnsFunction<org.teiid.translator.ExecutionContext, byte[]> orFunction<org.teiid.translator.ExecutionContext, String> orFunction<org.teiid.translator.ExecutionContext, InputStream> Where byte[], String and InputStream are response from the REST call made.- Returns:
- string - file/endpoint or name of the bean
-
-
-
source
String source
Source name; If overriding the org.teiid.translator.ws.WsExecutionFactory bean then provide the name of the bean- Returns:
- string
- Default:
- "rest"
-
-
-
root
String root
Root of the document where the parsing needs to start from.- Returns:
- string
- Default:
- "/"
-
-