How to include variables witin a raw string in Java?

Viewed 25

I'm trying to POST a JSON object in Java, in this instance I want to replace each of the numbers in the below code block with a variable for them instead (e.g. instead of 21 I'd like to have dataupdate.getID())

I've looked at string formatters but can't seem to get it to work with a JSON object, can any advise what I'm missing?

            var bodyMessage = """
    {"accountnumber":"21","reading":"1234","date":"07032014"}
""";

0 Answers
Related