Dulanjaya Tennekoon
Dulanjaya Tennekoon

Reputation: 2508

Encoding Python object (with Python Convention) in JSON with Java naming convention

I need to send an object from my Python project to my Java project by JSON encoding it.

However, according to naming conventions, python has fields like

variable_name

while Java has fields like

private String variableName

How to encode the python object with the above variable (variable_name) in JSON, so that I can decode that JSON object into a Java model (having field as variableName)?

Upvotes: 1

Views: 88

Answers (1)

Youcef LAIDANI
Youcef LAIDANI

Reputation: 60046

If you are using Jackson library, You can use :

@JsonProperty("variable_name") // same name come from python app
private String variableName;

Upvotes: 2

Related Questions