'Parse Json file in MongoDB using Spring Data Java

this problem only occurs when I get the data from the database, the application is replacing the _ with . this only happens when I get the record from the database

data in database

[{"nombre": "pablo", "pais(codigo)": "52", "telefono": "", "saldo_total": "10"}, {"nombre": "pablo", "pais(codigo)": "52", "telefono": "", "saldo_total": "10"}]

entity in java code

@EnableMongoRepositories
@Document(collection = "data")
public class DataEntity extends BaseMongoEntity {
    @Id
    private String id;
    @Field(value = "company_id")
    private int companyId;
    private String name;
    private String url;
    private List<String> variables;
    private List<Object> info;

    public DataEntity() {
        super();
        // TODO Auto-generated constructor stub
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public int getCompanyId() {
        return companyId;
    }

    public void setCompanyId(int companyId) {
        this.companyId = companyId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
    
    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public List<String> getVariables() {
        return variables;
    }

    public void setVariables(List<String> variables) {
        this.variables = variables;
    }


    public List<Object> getInfo() {
        return info;
    }

    public void setInfo(List<Object> info) {
        this.info = info;
    }

}

query to find the record in database

public DataEntity findById(String id) {
        ObjectId idO  = new ObjectId(id);
        Query query = new Query(Criteria.where("_id").is(idO));
        return mongoTemplate.findOne(query, DataEntity.class);
    }

image of data obtained in object format enter image description here

only happens when the record is obtained but not when saving data in the database.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source