1

I have JSON Array which I want to convert in some format which I can compare with datastax value. I tried below code:

String familyNames = response.jsonPath().getString("FAMILY");

and

List jsonresponse = response.jsonPath().getList("$");

I am not able to find any way. I expect a format in which I can comapre entire json response with the values in datastax table

Dolly
  • 97
  • 3
  • 18

1 Answers1

0

Consider blogs such as this one or this one or posts like this one or this one here:

import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;

....
String json = "[{\"name\":\"mkyong\", \"age\":37}, {\"name\":\"fong\", \"age\":38}]";
ObjectMapper mapper = new ObjectMapper();
List<Person> persons = Arrays.asList(mapper.readValue(json, Person[].class));

Or

String jsonString = "{'Bob' : {'name': 'Bob Willis'},"
    + "'Jenny' : {'name': 'Jenny McCarthy'}, "
    + "'Steve' : {'name': 'Steven Waugh'}}";
Gson gson = new Gson();
Type empMapType = new TypeToken<Map<String, Employee>>() {}.getType();
Map<String, Employee> nameEmployeeMap = gson.fromJson(jsonString, empMapType);
riorio
  • 6,500
  • 7
  • 47
  • 100