1

こんにちは私はそのように見えるjsonで応答があります

{
    "el": {
        "reviewed_percentage": "0%",
        "completed": "16%",
        "untranslated_words": 8,
        "last_commiter": "zaabalonso",
        "reviewed": 0,
        "translated_entities": 1,
        "translated_words": 1,
        "last_update": "2012-07-06 13:08:10",
        "untranslated_entities": 5
    },
    "en": {
        "reviewed_percentage": "0%",
        "completed": "100%",
        "untranslated_words": 0,
        "last_commiter": "zaabalonso",
        "reviewed": 0,
        "translated_entities": 6,
        "translated_words": 9,
        "last_update": "2012-07-06 12:28:48",
        "untranslated_entities": 0
    },
    "gl_ES": {
        "reviewed_percentage": "0%",
        "completed": "33%",
        "untranslated_words": 7,
        "last_commiter": "zaabalonso",
        "reviewed": 0,
        "translated_entities": 2,
        "translated_words": 2,
        "last_update": "2012-07-06 13:06:46",
        "untranslated_entities": 4
    }
}

javascriptを使用してそのように変換するにはどうすればよいですか?

[{
            "language"="el",
            "reviewed_percentage": "0%",
            "completed": "16%",
            "untranslated_words": 8,
            "last_commiter": "zaabalonso",
            "reviewed": 0,
            "translated_entities": 1,
            "translated_words": 1,
            "last_update": "2012-07-06 13:08:10",
            "untranslated_entities": 5},
........etc.
]
4

1 に答える 1

1

JSONデータをループして、以下の疑似コードを使用するなど、必要な形式で新しいデータセットを作成できます(oldJSONが投稿されたJSON応答として割り当てられていると仮定します)

var newData = [];
for ( var s in oldJSON )
{
    var data = oldJSON[s];
    data.language = s;
    newData.push(data);
}
于 2012-07-14T16:12:51.437 に答える