Hi,

I am trying JSON connector and facing issues while defining the multiple table 
based on below JSON.

{ "name": "VJ",
                "age": 29,
                "accounts": [{
                                "type": "Saving",
                                "name": "HDFC"}, {
                                "type": "Current",
                                "name": "SBI"}]}

Use case - Wanted to define two table out of above json with following fields

*         Employee - name & age

*         Accounts - name & type

So that user can fetch either data of employee or account or both using joins. 
I tried below code but it's not working

SimpleTableDef tableDef = new SimpleTableDef("employee", new String[] { "name", 
"age" });
SimpleTableDef accountDef = new SimpleTableDef("account", new String[] { 
"accounts.type", "accounts.name" });
SchemaBuilder schemaBuilder = new SimpleTableDefSchemaBuilder("myschema", 
tableDef, accountDef);
dataContext = new JsonDataContext(new InMemoryResource("x/y",stringToJSON(),new 
Date().getTime()),schemaBuilder);

Verified the test cases and found the way to create table in combine way by 
using definition[0] but when I say select accounts[0].type from employee  it 
only returns Saving instead of getting both Saving & Current


Can anyone please guide me to create multiple tables for above JSON data ?







[0] - SimpleTableDef tableDef = new SimpleTableDef("employee", new String[] { 
"name", "age", "accounts[0]", "accounts[0].type", "accounts[0].name" });


Regards,
Vijay Kumar J

Reply via email to