Skip to content
Advertisement

How to parse JSON String to java object with jackson?

I am currently having trouble trying to parse this VCAP_SERVICES to java objects. I do not quite understand how to structure the POJO to allow it to map the values from the json string. Can someone please help me structure my pojo so that it is aligns with the json string?

I want to create objects for both of the credentials: accessToken… jdbcurl.

VCAP_SERVICES

JavaScript

Java Class

JavaScript

POJOS

JavaScript

Error

Unrecognized field “user-provided” (class rest.springframework.model.CupsProperties), not marked as ignorable (2 known properties: “jdbcUrl”, “dataSource”]) at [Source: {“user-provided”:[{ “credentials”: { “jdbcUrl”: “jdbc:oracle:thin:user/pass//host:port/service”, “spring.datasource.driver-class-name”: “oracle.jdbc.OracleDriver”, “spring.datasource.initialize”: “false” }, “syslog_drain_url”: “”, “volume_mounts”: [ ], “label”: “user-provided”, “name”: “Oracle”, “tags”: [ ] }]}; line: 1, column: 19] (through reference chain: rest.springframework.model.CupsProperties[“user-provided”])

Advertisement

Answer

Check below solution and see if it fulfills your need. You can build on to it if you need to parse more fields.

JavaScript

Output

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement