私は組み込みシステムに取り組んでおり、プロセス全体に関する私の理論は次の方法論に従います。 1. バックエンドにコマンドを送信して、JSON 形式のアカウント情報を要求します。2. バックエンドは、すべてのアカウントと関連情報を含む JSON ファイルを書き込みます (0 から 16 のアカウントがある可能性があります)。3. ここで行き詰まります - JavaScript (JQuery ライブラリを使用しています) を使用して、返された特定の要素の情報を繰り返し処理し (XPath と同様)、見つかった要素の数に基づいて配列を作成し、ドロップダウンに入力しますボックスをクリックして、表示するアカウントを選択し、アカウント情報を操作します。したがって、私のコードは次のようになります。
loadAccounts = function()
{
$.getJSON('/info?q=voip.accounts[]', function(result)
{
var sipAcnts = $("#sipacnts");
$(sipAcnts).empty(); // empty the dropdown (if necessarry)
// Get the 'label' element and stick it in an array
// build the array and append it to the sipAcnts dropdown
// use array index to ref the accounts info and do stuff with it
}
そこで必要なのは、voip.accounts.label の配列を作成するための XPath の JSON バージョンです。最初のアカウント情報は次のようになります。
{
"result_set": {
"voip.accounts[0]": {
"label": "Dispatch1",
"enabled": true,
"user": "1234",
"name": "Jane Doe",
"type": "sip",
"sip": {
"lots and lots of stuff":
},
}
}
}
問題を複雑にしすぎていませんか? 誰もが投げ捨てることができる知恵は大歓迎です。