Home > Net >  How to Send this kind of Json Response
How to Send this kind of Json Response

Time:02-12

How To Send the Kind of api response when i am sending then the first letter become small I want response key VehicleNumber but i am getting vehicleNumber the First letter small i ma getting

    "status": "1",
    "data": [
        {
            "VehicleNumber": "DL1ZD1455",
            "Address": "gurgaon sector 48,sector 48, gurgaon",
            "Latitude": 28.42682,
            "Longitude": 77.03228,
            "Alerttime": "dd/MM/yyyy HH:mm:ss",
            "Speed": "21.000",
        }
    ],
    "message": "Success"
}```


i am getting this kind of response

{ "status": "1", "data": [ { "address": "Lucknow Airport Terminal,Uttar Pradesh", "vehicleNumber": "DL1PD3231", "speed": "0", "latitude": 26.76383, "longitude": 80.88558, "alerttime": "2021-12-19 17:16:41" } ], "message": "Success" }

CodePudding user response:

You can extend com.fasterxml.jackson.databind.PropertyNamingStrategy and override translate method and do something like this:

public static class UpperCaseJsonStrategy extends PropertyNamingStrategyBase {
    @Override
    public String translate(String input) {
        return str.charAt(0).toUpperCase()   str.slice(1);
    }
}

CodePudding user response:

Please again describe clearly ...

  • Related