Here the Json example I need to Marshal:

{ "status": "success", "postcode": "W14", "postcode_type": "district", 
"url": "https://propertydata.co.uk/draw?input=W14";, "data": [ [ "Aug 2013", 
862199, null ], [ "Aug 2014", 1039052, "20.5%" ], [ "Aug 2015", 1069005, 
"2.9%" ], [ "Aug 2016", 1077210, "0.8%" ], [ "Aug 2017", 1123564, "4.3%" ], 
[ "Aug 2018", 1109593, "-1.2%" ] ], "process_time": "0.57" }

and here the Pojo:

@Setter
@EqualsAndHashCode
public class GrowthStats {
public String status;
public String postcode;
public String postcode_type;
public Long effective_date;
public String url;
public List<List<String>> data;
public String process_time;

@ProtoField(number = 1)
public String getStatus() {
return status;
}

@ProtoField(number = 2)
public String getPostcode() {
return postcode;
}

@ProtoField(number = 3)
public String getPostcode_type() {
return postcode_type;
}

@ProtoField(number = 4)
public Long getEffective_date() {
return effective_date;
}

@ProtoField(number = 5)
public String getUrl() {
return url;
}

@ProtoField(number = 6)
public List<List<String>> getData() {
return data;
}

@ProtoField(number = 7)
public String getProcess_time() {
return process_time;
}
}


On Friday, 21 May 2021 at 16:59:44 UTC+1 Simone Di Cola wrote:

>
> ````quote
> I have the following field 
> ```
> public List<List<String>> data;
> ```
>
> That I need to serialise using protobuf (for infinispan-client).
>
> I am trying to annotate the getter this way
> ```
>     @ProtoField(number = 6)
>     public List<List<String>> getData() {
>         return data;
>     }
> ```
> But I got:
> ```
> org.infinispan.protostream.annotations.ProtoSchemaBuilderException: The 
> type java.util.List of field 'data' of xyz.property.data.model.GrowthStats 
> should not be abstract.
> ```
>
> Hence I created another class called Data:
> ```
> @Setter
> @EqualsAndHashCode
> public class Data {
>
>     List<String> stats;
>
>     @ProtoField(number = 1, collectionImplementation = ArrayList.class)
>     public List<String> getStats() {
>         return stats;
>     }
> }
> ```
> and modified the main class this way:
>
> ```
>     public List<Data> data;
>
>     @ProtoField(number = 6, collectionImplementation = ArrayList.class)
>     public List<Data> getData() {
>         return data;
>     }
> ```
> And I created this:
> ```
> @AutoProtoSchemaBuilder(includeClasses = {GrowthStats.class, Data.class}, 
> schemaPackageName = "stats.data.xyz.property")
> public interface GrowthContextInitializer extends 
> SerializationContextInitializer {
> }
> ```
> ````
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/protobuf/08523782-d46b-4f1a-944d-03372a1ff7d9n%40googlegroups.com.

Reply via email to