how to parse json using groovy

Have you tried using JsonSlurper? Example usage: def slurper = new JsonSlurper() def result = slurper.parseText(‘{“person”:{“name”:”Guillaume”,”age”:33,”pets”:[“dog”,”cat”]}}’) assert == “Guillaume” assert result.person.age == 33 assert result.person.pets.size() == 2 assert result.person.pets[0] == “dog” assert result.person.pets[1] == “cat”

How do I search for a specific string in a JSON Postgres data type column?

In Postgres 11 or earlier it is possible to recursively walk through an unknown json structure, but it would be rather complex and costly. I would propose the brute force method which should work well: select * from reports where params::text like ‘%authVar%’; — or — where params::text like ‘%”authVar”%’; — if you are looking …

Read more

RestTemplate PATCH request

I solved this problem just adding a new HttpRequestFactory to my restTemplate instance. Like this RestTemplate restTemplate = new RestTemplate(); HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(); requestFactory.setConnectTimeout(TIMEOUT); requestFactory.setReadTimeout(TIMEOUT); restTemplate.setRequestFactory(requestFactory); For TestRestTemplate, add @Autowired private TestRestTemplate restTemplate; @Before public void setup() { restTemplate.getRestTemplate().setRequestFactory(new HttpComponentsClientHttpRequestFactory()); } PS: You will need add httpClient component in your project <dependency> <groupId>org.apache.httpcomponents</groupId> …

Read more