简体   繁体   English

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

[英]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.我需要将 object 从我的 Python 项目发送到我的 Java 项目,通过 Z0ECD11C1D7A28740F8D1 编码它。

However, according to naming conventions , python has fields like但是,根据命名约定, python 具有如下字段

variable_name

while Java has fields like而 Java 有如下字段

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)? 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)?

If you are using Jackson library, You can use:如果您使用的是 Jackson 库,您可以使用:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM