mercredi 6 septembre 2017

Generate JSON from Nested input checkbox values

I am getting nested input checkbox tags in divs as shown in image enter image description here

[PROBLEM] At the bottom of my page, I have a submit button, when I click on it I want to form a JSON of checked values with their parent nodes. So like if I check a key with a value, I should get its parent keys along with it. For example: I have selected ServiceName and officeID in TransactionDetails, and some array values in BillDetails, so I should get something like this

{
    "FetchDetails": {
        "TransactionDetails": {
            "ServiceName": "Airtel Mobile Bill Postpaid",
            "officeID": "209"
        },
        "BillDetails": [{
            "LableName": "Amount Before Due Date",
            "LableValue": "931.00"
        }, {
            "LableName": "Due Date",
            "LableValue": "NA"
        }, {
            "LableName": "Account Number",
            "LableValue": "1116231291"
        }]
    }
}

[Refer to this question for complete scenario]

Aucun commentaire:

Enregistrer un commentaire