1

I have a JSON text (posted below) and I want to extract name and channel_remote_number from each of its object inside its item array. Can someone please guide how can I do that?

JSON Text:

{  
   "xml":{  
      "version":"3.0.0",
      "item_startidx":"0",
      "total_items":"471",
      "items_link":"https://example_url/",
      "items":{  
         "item":[  
            {  
               "id":"36438",
               "name":"A plus",
               "type":"liveWMV",
               "link":"https://example_url/",
               "duration":"35000",
               "channel_logo":{  
                  "#cdata":"http://example_url/"
               },
               "channel_remote_number":"180",
               "description":"A plus",
               "response_link":"https://example_url/",
               "restrict_link":"https://example_url/",
               "play_time":"https://example_url/",
               "protected":"no",
               "program_listing":"https://example_url/",
               "program_guide":"https://example_url/",
               "electronic_program_guide":"https://example_url/",
               "catchup_tv":"7",
               "popup":{  
                  "type":"blocking",
                  "message":"Temporary Down",
                  "buttons":{  
                     "button":{  
                        "type":"cancel",
                        "text":"OK"
                     }
                  }
               },
               "category_id":"12797",
               "path":"Smart TV App>Live TV>Pakistani>Entertainment"
            },
            {  
               "id":"37669",
               "name":"A plus",
               "type":"liveWMV",
               "link":"https://example_url/",
               "duration":"35000",
               "channel_logo":{  
                  "#cdata":"http://example_url/"
               },
               "channel_remote_number":"180",
               "description":"A plus",
               "response_link":"https://example_url/",
               "restrict_link":"https://example_url/",
               "play_time":"https://example_url/",
               "protected":"no",
               "program_listing":"https://example_url/",
               "program_guide":"https://example_url/",
               "electronic_program_guide":"https://example_url/",
               "catchup_tv":"7",
               "popup":{  
                  "type":"blocking",
                  "message":"Temporary Down",
                  "buttons":{  
                     "button":{  
                        "type":"cancel",
                        "text":"OK"
                     }
                  }
               },
               "category_id":"12797",
               "path":"Smart TV App>Live TV>Pakistani>Entertainment"
            }
          ]
        }
    }
}

1 Answer 1

1
var data = {  
              "xml": {....

var answer = data.xml.items.item
      .map(x => ({ name: x.name, channel_remote_number: x.channel_remote_number }));
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.