ネストされたjsonがextjsで利用可能かどうかについて、さまざまな場所から競合する情報を取得します。NBは物事を複雑にしているかもしれないSenchaArchitectを使用しています...
ストア/ajaxプロキシを介して返されるクライアントjsonオブジェクトがあります。最初のレベルを超えて何にもアクセスできません。
JSONは次のようになります。
{
"client": {
"0": {
"id": "12345",
"type_id": "3",
"association_id": "0",
"is_active": "1",
"manager_id": "2",
"business_name": null,
"has_payroll": "0",
"business_proprietor_contact_id": null,
"date_created": "1358893243",
"date_modified": "1358893243"
},
"contacts": [
{
"id": "1",
"client_id": "12345",
"contact_id": "1",
"is_primary": "0",
"display_priority": "0",
"relationship": "Client",
"friendly_name": "Homer",
"contact": [
{
"id": "1",
"surname": "Mr.",
"first_name": "Homer",
"middle_name": "J",
"last_name": "Simpson",
"client_id": "12345",
"date_created": "1356038714",
"date_modified": null
},
{
"addresses": [
{
"id": "1",
"contact_id": "1",
"address_id": "16",
"is_mailing_address": "0",
"is_primary_address": "0",
"display_priority": "0",
"address": {
"0": {
"id": "16",
"address": "5 Dirt Rd",
"address2": "",
"city": "TAXMASTER",
"state": "NY",
"zip_code": "454545",
"country": "USA",
"other": null,
"phone": null,
"fax": null,
"display_priority": null,
"is_mailing_address": "1"
},
"data": [
{
"id": "10",
"label": "Phone",
"value": "BUT WHO WAS",
"date_created": "1356104685",
"date_modified": "1357142782",
"user_id": null,
"display_priority": null,
"client_id": null,
"contact_id": null,
"account_id": null,
"business_id": null,
"address_id": "16",
"is_deleted": "0"
},
{
"id": "14",
"label": "Fax",
"value": "simile",
"date_created": "1356557379",
"date_modified": "1357142782",
"user_id": null,
"display_priority": null,
"client_id": null,
"contact_id": null,
"account_id": null,
"business_id": null,
"address_id": "16",
"is_deleted": "0"
},
{
"id": "17",
"label": "Also Known as:",
"value": "DUDE",
"date_created": "1357141357",
"date_modified": "1357142782",
"user_id": null,
"display_priority": null,
"client_id": null,
"contact_id": null,
"account_id": null,
"business_id": null,
"address_id": "16",
"is_deleted": "0"
}
]
}
},
{
"id": "6",
"contact_id": "1",
"address_id": "26",
"is_mailing_address": "0",
"is_primary_address": "0",
"display_priority": "0",
"address": {
"0": {
"id": "26",
"address": "1 Lift Road",
"address2": "",
"city": "Tony Beach",
"state": "KS",
"zip_code": "15151",
"country": "USA",
"other": null,
"phone": null,
"fax": null,
"display_priority": null,
"is_mailing_address": "0"
},
"data": [
{
"id": "18",
"label": "Phone:",
"value": "cool phone number",
"date_created": "1357141527",
"date_modified": "1357141527",
"user_id": null,
"display_priority": null,
"client_id": null,
"contact_id": null,
"account_id": null,
"business_id": null,
"address_id": "26",
"is_deleted": "0"
},
{
"id": "19",
"label": "Note:",
"value": "cool note",
"date_created": "1357141527",
"date_modified": "1357141527",
"user_id": null,
"display_priority": null,
"client_id": null,
"contact_id": null,
"account_id": null,
"business_id": null,
"address_id": "26",
"is_deleted": "0"
}
]
}
},
],
"data": [
{
"id": "1",
"label": "asdf",
"value": "dfdfefefefef",
"date_created": "1356038714",
"date_modified": "1356040822",
"user_id": "2",
"display_priority": "0",
"client_id": null,
"contact_id": "1",
"account_id": null,
"business_id": null,
"address_id": null,
"is_deleted": "0"
},
{
"id": "2",
"label": "asfd",
"value": "152151",
"date_created": "1356038714",
"date_modified": "1356040822",
"user_id": null,
"display_priority": "2",
"client_id": null,
"contact_id": "1",
"account_id": null,
"business_id": null,
"address_id": null,
"is_deleted": "0"
},
]
}
]
},
{
"id": "7",
"client_id": "12345",
"contact_id": "11",
"is_primary": "0",
"display_priority": "0",
"relationship": "None",
"friendly_name": "Mary Jane",
"contact": {
"0": {
"id": "11",
"surname": "",
"first_name": "Mary Jane",
"middle_name": "",
"last_name": "Simpson",
"client_id": null,
"date_created": "1357145795",
"date_modified": null
},
"7": {
"addresses": [
{
"id": "11",
"contact_id": "11",
"address_id": "33",
"is_mailing_address": "0",
"is_primary_address": "0",
"display_priority": "0",
"address": {
"0": {
"id": "33",
"address": "33 Street",
"address2": "",
"city": "NY",
"state": "NY",
"zip_code": "06830",
"country": "USA",
"other": null,
"phone": null,
"fax": null,
"display_priority": null,
"is_mailing_address": "0"
},
"data": [
{
"id": "31",
"label": "Fax:",
"value": "asdfasdf",
"date_created": "1357145905",
"date_modified": "1357145939",
"user_id": null,
"display_priority": null,
"client_id": null,
"contact_id": null,
"account_id": null,
"business_id": null,
"address_id": "33",
"is_deleted": "0"
},
{
"id": "32",
"label": "Fax:",
"value": "sadfsadf",
"date_created": "1357145905",
"date_modified": "1357145905",
"user_id": null,
"display_priority": null,
"client_id": null,
"contact_id": null,
"account_id": null,
"business_id": null,
"address_id": "33",
"is_deleted": "0"
}
]
}
}
],
"data": [
{
"id": "29",
"label": "Phone:",
"value": "asdfsadf",
"date_created": "1357145833",
"date_modified": "1357145833",
"user_id": "2",
"display_priority": null,
"client_id": null,
"contact_id": "11",
"account_id": null,
"business_id": null,
"address_id": null,
"is_deleted": "0"
},
{
"id": "30",
"label": "Email:",
"value": "dsfgdsfg",
"date_created": "1357145855",
"date_modified": "1357145855",
"user_id": "2",
"display_priority": null,
"client_id": null,
"contact_id": "11",
"account_id": null,
"business_id": null,
"address_id": null,
"is_deleted": "0"
}
]
}
}
}
],
"notes": [
{
"id": "5",
"client_id": "12345",
"label": "This is a HomerHomer Note",
"value": "This is from Homer's Dashboard Notes.",
"contact_id": null,
"address_id": null,
"account_id": null,
"account_data_id": null,
"account_credential_id": null,
"payment_id": null,
"contact_log_id": null,
"user_id": "2",
"bill_id": null,
"is_deleted": "0",
"date_created": "1357148256",
"date_modified": "1357148256"
}
]
}
}
https://stackoverflow.com/a/8318589/183254によると、ネストされたJSONは利用できません。https://stackoverflow.com/a/5604594/183254によると、利用可能ですが、特定の形式である必要があります。
APIドキュメント形式に基づいて少しテストを行いました。
{
results: 2000,
rows: [
{ id: 1, firstname: 'Bill', occupation: 'Gardener', cool: {neat: 'wow'} },
{ id: 2, firstname: 'Ben' , occupation: 'Horticulturalist' },
]
}
これが入ってくると、私はtplからすべてを呼び出すことができます。特に、をcool.neat
印刷しwow
ます。ただし、休憩に変更cool
します。cool:[{neat:'wow}]
したがって、ネストされたjsonは部分的に機能しているようです。おそらく、私が何か間違ったことをしているために部分的にしか機能していません。
私の考えでは、必要なデータのすべてのグループのプロキシを作成するのではなく、APIに対して単一のリクエストを実行し、必要なすべての情報を収集して解析し、コンポーネントに送信する方が理にかなっています。私は間違っているかもしれません...
必要なガイダンス/フェイスパンチに加えて、2つの質問があります。
1)私がやっていることを試してみるのは可能/実用的ですか?つまり、単一のリクエストを使用して複数のコンポーネントのデータを収集しようとしていますか?
2)tplからデータをデバッグする方法はありますか?
これはSenchaArchitect経由のextjs4.1です
ありがとう。