manish ranjan
manish ranjan

Reputation: 1

Rest web service JSON request body with "truee" as boolean true value

In a REST web service, the POST JSON body is like this:

{
    "printRequest" : {
        "printName" : "XYZ",
        "enable" : "truee",
        "printerDescription" : "anyString",
        "connectionString" : "YYYY",
        "ABC" : "XXX"
    }
}

Here attribute enable is of boolean type, but with extra "e" in "true". How do I deserialize it as plain Java boolean?

Upvotes: 0

Views: 1841

Answers (1)

user5547025
user5547025

Reputation:

JSON supports real booleans:

true
false

Note that there are not quotes. "true" is not a JSON boolean but a JSON string.

Do yourself a favour and fix the client to send this:

{
    "printRequest": {
        "printName": "XYZ",
        "enable": true,
        "printerDescription": "anyString",
        "connectionString": "YYYY",
        "ABC": "XXX"
    }
}

Upvotes: 1

Related Questions