Re: [Geojson] Question regarding RFC 7946

Erik Wilde <erik.wilde@dret.net> Mon, 18 March 2019 09:28 UTC

Return-Path: <erik.wilde@dret.net>
X-Original-To: geojson@ietfa.amsl.com
Delivered-To: geojson@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id C55A4128CE4 for <geojson@ietfa.amsl.com>; Mon, 18 Mar 2019 02:28:55 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -0.002
X-Spam-Level:
X-Spam-Status: No, score=-0.002 tagged_above=-999 required=5 tests=[BAYES_20=-0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id mWxEeDnMlFuU for <geojson@ietfa.amsl.com>; Mon, 18 Mar 2019 02:28:54 -0700 (PDT)
Received: from postoffice.gristmillmedia.com (dret.net [209.188.86.86]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 288C012716C for <geojson@ietf.org>; Mon, 18 Mar 2019 02:28:54 -0700 (PDT)
Received: from 73.10.0.85.dynamic.wline.res.cust.swisscom.ch ([85.0.10.73]:62466 helo=dretpro.home) by postoffice.gristmillmedia.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.91) (envelope-from <erik.wilde@dret.net>) id 1h5oZf-00082t-Dl; Mon, 18 Mar 2019 05:28:51 -0400
To: Martin Daly <Martin.Daly@cadcorp.com>, "'V. Kelly Bellis'" <kellybellis@gwi.net>, "geojson@ietf.org" <geojson@ietf.org>
References: <86310cf6-e2d8-6c59-c845-b9862ba414a1@gwi.net> <CAOoFiBbxxH0h3xA=i_+G94Feb-Mh6yEfTEw71o-HH=tCkiU=Xg@mail.gmail.com> <589847ca-db3d-853e-1142-cbe0b3e61da5@gwi.net> <b95480321c1e498189ec72533a0b4c9f@SRV016VEX.cadcorp.net>
From: Erik Wilde <erik.wilde@dret.net>
Message-ID: <601730f4-f3ba-6d65-819b-3da80f72d1e8@dret.net>
Date: Mon, 18 Mar 2019 10:28:49 +0100
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:60.0) Gecko/20100101 Thunderbird/60.5.3
MIME-Version: 1.0
In-Reply-To: <b95480321c1e498189ec72533a0b4c9f@SRV016VEX.cadcorp.net>
Content-Type: text/plain; charset="utf-8"; format="flowed"
Content-Language: en-US
Content-Transfer-Encoding: 8bit
X-AntiAbuse: This header was added to track abuse, please include it with any abuse report
X-AntiAbuse: Primary Hostname - postoffice.gristmillmedia.com
X-AntiAbuse: Original Domain - ietf.org
X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12]
X-AntiAbuse: Sender Address Domain - dret.net
X-Get-Message-Sender-Via: postoffice.gristmillmedia.com: authenticated_id: birdhouse@dret.net
X-Authenticated-Sender: postoffice.gristmillmedia.com: birdhouse@dret.net
X-Source:
X-Source-Args:
X-Source-Dir:
Archived-At: <https://mailarchive.ietf.org/arch/msg/geojson/Ere9WVQiqMFCUkZAyyO6wfhnIKc>
Subject: Re: [Geojson] Question regarding RFC 7946
X-BeenThere: geojson@ietf.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: IETF GeoJSON WG <geojson.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/geojson>, <mailto:geojson-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/geojson/>
List-Post: <mailto:geojson@ietf.org>
List-Help: <mailto:geojson-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/geojson>, <mailto:geojson-request@ietf.org?subject=subscribe>
X-List-Received-Date: Mon, 18 Mar 2019 09:28:56 -0000

hello.

On 2019-03-18 10:06, Martin Daly wrote:
> You have no “FeatureCollection” object, and therefore no “features” 
> array. Your “properties” object does not have commas between consecutive 
> key/value pairs. That’s two problems to be going on with.
> 
> You can use jsonlint.com and geojsonlint.com to check your output, which 
> may give clearer errors than you have been getting.

tl;dr: always pick the right tool for the job.

martin is kind of right, but i think he's not going far enough. these 
JSON problems tell you that it's not such a great idea to edit JSON via 
regexes. to understand why, here's is the greatest answer ever about why 
regex as a tool is limited in its applicability to complex data:

https://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454

i'd highly recommend to parse the JSON using a JSON parser of your 
choice (you'll find one in any programming language), do your 
transformation magic on the parse tree, and then serialize the result.

you will find this to be much more robust, extensible, and predictable, 
even though it may seem like a bit of overkill in the beginning.

cheers,

dret.

-- 
erik wilde | mailto:erik.wilde@dret.net |
            | http://dret.net/netdret    |
            | http://twitter.com/dret    |