I have a JSON file like this :
{
"rewrite_url_captures": [
{
"description": [
"Captures arguments in a URL and rewrites the URL using these arguments. "
],
"configuration": {},
"name": "URL Rewriting with Captures"
}
],
"routing": [
{
"description": [],
"configuration": {},
"name": "Routing"
}
],
"soap": [
{
"description": [
"This policy adds support for a very small subset of SOAP."
],
"configuration": {},
"name": "SOAP"
}
]
}
I would like to get the names of these 3 objects: rewrite_url_captures, routing, soap.
I already did this :
import java.util.ArrayList;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({
"rewrite_url_captures"
})
public class PoliciesTest {
protected ArrayList<PolicyTest> policy;
@JsonProperty("rewrite_url_captures")
public ArrayList<PolicyTest> getPolicy() {
if (policy == null) {
policy = new ArrayList<PolicyTest>();
}
return this.policy;
}
}
That calls this class :
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({
"name"
})
public class PolicyTest {
@JsonProperty("name")
private String name;
public Object getName() {
return name;
}
}
I get this as output so it works :
My problem is that I can only access the 3 objects one by one by modifying the JSON property with the corresponding name in the PoliciesTest class, except I would like to have the 3 at once as an output and I can't overload the @JSONProperty.
Has anyone faced this problem before?