0
我有一個JSON對象的結構是這樣的:重組JSON對象
[
{"CodeId": 1,"Description": "DESC1","Text": "TEXT 1 GB en","CodeCountry": "GB","CodeLanguage": "en"},
{"CodeId": 1,"Description": "DESC1","Text": "TEXT 1 BE fr","CodeCountry": "BE","CodeLanguage": "fr"},
{"CodeId": 1,"Description": "DESC1","Text": "TEXT 1 BE nl","CodeCountry": "BE","CodeLanguage": "nl"},
{"CodeId": 2,"Description": "DESC2","Text": "TEXT 2 DE de","CodeCountry": "DE","CodeLanguage": "de"},
{"CodeId": 2,"Description": "DESC2","Text": "TEXT 2 GB en","CodeCountry": "GB","CodeLanguage": "en"},
{"CodeId": 2,"Description": "DESC2","Text": "TEXT 2 BE nl","CodeCountry": "BE","CodeLanguage": "nl"}
]
,我想它重組這樣的:
[
{
"CodeId": 1,
"Description": "DESC1",
"languages":
[
{"Text": "TEXT 1 GB en","CodeCountry": "GB","CodeLanguage": "en"},
{"Text": "TEXT 1 BE fr","CodeCountry": "BE","CodeLanguage": "fr"},
{"Text": "TEXT 1 BE nl","CodeCountry": "BE","CodeLanguage": "nl"},
]
},
{
"CodeId": 2,
"Description": "DESC2",
"languages":
[
{"Text": "TEXT 2 DE de","CodeCountry": "DE","CodeLanguage": "de"},
{"Text": "TEXT 2 GB en","CodeCountry": "GB","CodeLanguage": "en"},
{"Text": "TEXT 2 BE nl","CodeCountry": "BE","CodeLanguage": "nl"},
]
},
]
有沒有人誰可以幫助?
其實我想填充table
與使用AngularJS
服務器數據,我沒有訪問到服務器,但我可以創建一個JS
功能與數據玩。
我已經嘗試使用AngularJS
中的過濾器來填充表格,但我正在使用分頁模塊,並且我嘗試使用這種方法時遇到問題。
我相信,我唯一的解決方案是創建一個JS
函數改變JSON
,但如果有人有其他的解決方案,我在這裏聽到的!
感謝;)
在你的情況,分組將在代碼ID的基地完成,說明? –
是的,每個CodeID的描述是唯一的,所以CodeID分組@AmitSoni – ben
@charlietfl我已經提出了這樣的解決方案,但正如我所說我正在使用兩個不同的模塊'angularUtils.directives.dirPagination'和'angular.filter' 。有了這個解決方案,我有很多問題與分頁 – ben