Thursday, October 12, 2017

How to Convert 2 Arrays to JSON using AngularJS

I have the following 2 integer arrays along with a denied reason:

var approvedItems = [2051, 2567];
    var deniedItems = [2053, 2569];
string deniedReason = "Naughty";

I want to create the following JSON:

{
    "Responses": [{
        "ResponseID": 2051,
        "IsApprove": true
    },
    {
        "ResponseID": 2567,
        "IsApprove": true
    },
    {
        "ResponseID": 2053,
        "IsApprove": false
    },
    {
        "ResponseID": 2569,
        "IsApprove": false
    }],
    "Reason": "Naughty"
}

How can I do that using angular/javascript?

Source: AngularJS



from Angular Questions https://angularquestions.com/2017/10/12/how-to-convert-2-arrays-to-json-using-angularjs/
via @lzomedia #developer #freelance #web #lzomedia.com

No comments:

Post a Comment