php - How to merge JSON two indexes and then Parse information -
I'm trying to iterate both JSON (player and building), so that I I can do jQuery I have two indexes: JSON is information about the player and there is information about the player building related to being related to another Indian. I want to parse it so that I can get the player and its building name. My actual JSON result Here you can go, It goes for each player and check whether there are buildings and what will be the map for the new structure. This will not filter the prices of buildings that do not mapping the players, and in this there are no untested buildings Will not include {{"Id": "35", "room_num": "8", "room_num": "101", {{id}: "10", "room_num": "9", "room_name": "102", {{id}: "11", "room_num": "104", "building_id": " "" "ID": "id": "id": "id": "id": "id": "id": "id": "" "id": "38", "building_id": "11"} "," "id": "" "id": "adi": "{" id ":" 8 " "Name": "id": "" "name": "id": "", "name" ":" JKL "}}}; Var res = $ .map (x. Player, function (item) {returns {player_id: item.id, building_name: $ .grep (x. Building, function (i) {return i.id == item.building_id}) .length! = 0? $ .grep (x Building, function (i) {return i.id == item.building_id}) [0] .name: undefined}}) And if you want to filter the values that do not have relationships such as INNER
{"player": "[35]" "building": "8", "room_name": "" "Id": "36", "building_id": "9", "38", "building_id": "10", "room_num": "103",}, "id": " 38 "," building_id ":" 11 "," room_num ":" 104 ",}]," building ": [{" id ":" 8 "," name ":" ABC "}, {" id " "9", "name": "id": "id": "10", "name": "ghi"}, {"id": "11", "name": "jkl"}}} "Player_id": "38", "building_name": "ghi"}, {"player_id": "38", "ABC"}, {"player_id": "36", "building_name": "def"}, {"player_id" , "Building_name": "JKL"}}}
var resInnerJoin = $ .grep ($. Map (x.Players, function) { Return} {player_id: Item.id, building_name: $ .grep (X. Building, Function (i) {Return i.id == item.building_id} Length! = 0? $ .grep (X. Building, Funk (I) {return I.id == item.building_id}) [0] .name: undefined}}, function (this) {return.building_name! = Undefined})
Comments
Post a Comment