Thank You.
setEncodeNullValues will solve my problem.
Regards,
Sunish.
On Fri, Feb 7, 2014 at 5:42 PM, William Voorsluys <williamv...@gmail.com>wrote:
> Hello,
>
> When writing, FeatureJSON will encode null values if
> setEncodeNullValues is called. In your case, the flag is probably
> false.
>
> When reading, it will obtain all properties and determine their types
> from the first feature only. In your case, REMARKS does not appear in
> the first feature, but later in the GeoJSON.
> The solution for that is calling readFeatureCollectionSchema to obtain
> a SimpleFeatureType and give to FeatureJSON with setFeatureType,
> before calling readFeatureCollection. readFeatureCollectionSchema will
> parse the JSON to obtain property types only, and
> readFeatureCollection will do second parse to read the actual
> features. Note you will parse the JSON twice, so you will need to
> reopen your InputStream before the second parse.
>
> Will
>
> On Fri, Feb 7, 2014 at 8:06 PM, sunish <sunish.ku...@gmail.com> wrote:
> > Hello,
> >
> > I am using geotools 10.3
> > I am converting featurecollection to JSON fjson.writeFeatureCollection().
> >
> > After words when I convert it back to featurecollection using
> > fjson.readFeatureCollection() sometimes I am getting error.
> > java.lang.IllegalArgumentException: No such attribute:REMARKS
> >
> > The problem appears if the REMARKS attribute is null for some records in
> the
> > original featurecollection. This error happens if the attribute is null
> in
> > the first record. The null attributes are not getting added to JSON
> Feature.
> > So while rebuilding featurecollection it is creating FeatureType based on
> > attributes of first feature. Subsequently when the attribute appears in
> > later feature it throws exception.
> >
> > I could find this piece of code in toJSONString of FeatureEncoder in
> > FeatureJSON
> >
> > if (!encodeNullValues && value == null) {
> > //skip
> > continue;
> > }
> >
> >
> > Is it a bug?
> >
> > Regards,
> > Sunish.
> >
> >
> >
> >
> >
> ------------------------------------------------------------------------------
> > Managing the Performance of Cloud-Based Applications
> > Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
> > Read the Whitepaper.
> >
> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
> > _______________________________________________
> > GeoTools-GT2-Users mailing list
> > GeoTools-GT2-Users@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
> >
>
------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
_______________________________________________
GeoTools-GT2-Users mailing list
GeoTools-GT2-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users