A WFS server exposes in which data formats it can return the features. Typically the server supports GML, but sometimes WFS servers also supports GeoJSON.

The default WFS client in LuciadLightspeed only requests data in the GML format. In order to support GeoJSON (or any other format), you need to:

As an example, the following ILcdWFSModelDecoder implementation (copied from the samples.ogc.wfs.client.WFSModelFactory sample class) supports GeoJSON:

/**
 * Implementation of <code><ILcdWFSModelDecoder/code> supports reading WFS content encoded in the GeoJSON format.
 */
private static class WFSGeoJsonModelDecoder implements ILcdWFSModelDecoder {

  private static final String[] JSON_FORMATS = {"application/json", "json"};

  @Override
  public boolean canDecodeModel(String aOutputFormat) {
    for (String jsonFormat : JSON_FORMATS) {
      if (aOutputFormat.equals(jsonFormat)) {
        return true;
      }
    }
    return false;
  }

  @Override
  public ILcdModel decodeModel(String aOutputFormat, String aContentType, InputStream aInputStream, String aSourceName, Properties aRequestProperties) throws IOException {
    TLcdGeoJsonModelDecoder delegate = new TLcdGeoJsonModelDecoder();
    delegate.setInputStreamFactory(source -> aInputStream);
    return delegate.decode("dummy.json");
  }
}

This decoder is registered on the TLcdWFSProxyModel.Builder using the modelDecoder method:

// By default, TLcdWFSProxyModel supports GML-based content (GML 2, 3.1, 3.2), the default WFS exchange format.
// We can also add support for other exchange formats, such as GeoJSON.
for (String format : WFSGeoJsonModelDecoder.JSON_FORMATS) {
  modelBuilder.modelDecoder(format, new WFSGeoJsonModelDecoder());
}