0

I need to convert the kebab case into camel case.

The depth of the JSON object can be up to 5 child elements. I tried to implement it (see here), but the output is not the expected.

Input:

{
    "is-success": true,
    "response-date": "2019-02-20T11:42:11.963Z",
    "result": {
        "record-count": "abc123",
        "bill-details-list": [
            {
                "source-system": "Abc123",
                "bill-info": {
                    "bill-amount": "Abc123"
                }
            },
            {
                "SourceSystem": "abc123",
                "bill-info": {
                    "bill-amount-po": "Abc123"
                }
            }
        ]
    }
};

Current output:

{
  isSuccess: true,
  responseDate: '2019-02-20T11:42:11.963Z',
  result: { recordCount: 'abc123', 'billDetailsList': [ [Object], [Object] ] }
}

Expected output:

{
    "isSuccess": true,
    "responseDate": "2019-02-20T11:42:11.963Z",
    "result": {
        "recordCount": "abc123",
        "billDetailsList": [
            {
                "sourceSystem": "Abc123",
                "billInfo": {
                    "billAmountPo": "Abc123"
                }
            },
            {
                "sourceSystem": "abc123",
                "billInfo": {
                    "billAmountPo": "Abc123"
                }
            }
        ]
    }
};
ericmp
  • 1,163
  • 4
  • 18
Diya
  • 43
  • 1
  • 9

0 Answers0