| The GeoJson writer (It is used in the GeoJSON PPIO class of geoserver) writes the class-type attributes of a SimpleFeature as string. We can define this code...
public class RefPar {
public int municipio;
public int poligono;
public int parcela;
}
...
SimpleFeatureTypeBuilder resultTypeBuilder = new SimpleFeatureTypeBuilder();
resultTypeBuilder.init(...);
resultTypeBuilder.minOccurs(1).maxOccurs(1).nillable(false).add("Ref", RefPar.class);
...
feature = SimpleFeatureBuilder.build(resultFeatureType, f.getAttributes(), f.getID());
feature.setAttribute("ref", new RefPar());
...
We get this Json... { name: "parcel_9985", area: 2234.345, ref: "municipio=211 poligono=2 parcela=356" } The "ref" member is not created as a normal Json object but as a stringfied representation of the object. The solution could be to change the code to check if the attribute value is a class and then visit its members to write them within a new child Json object. |