Pages

Tuesday, 30 July 2024

Multiple json items numeric value conversion

If there are multiple items where we need to convert to interger, we need to follow.the below logic.


Data Input:

{

    "Document": [

        {

            "Division": "04",

            "ItemNumber": "100332",

            "Customer": "200006",

            "BranchID": "0554",

            "NonFlag": "N",

            "UpdateType": "R"

        },

        {

            "Division": "04",

            "ItemNumber": "100210",

            "Customer": "200006",

            "BranchID": "0554",

            "NonFlag": "N",

            "UpdateType": "R"

        }

    ]

}

 

For multiple items we need add [0]:


For single item script will be like this

 

jsonDataObject.Document.BranchID = convertToInt(jsonDataObject.Document.BranchID);  

 

For multiple item script will be like this

 

jsonDataObject.Document[0].BranchID = convertToInt(jsonDataObject.Document[0].BranchID);

No comments:

Post a Comment