FAQ
Hi, folks.

I have written a JSON pre-processor in Go.
https://github.com/hnakamur/jsonpreprocess

It does:
   - trim comments
   - minify (trim comments and whitespaces)

The lexer core implementation is based on
   - Lexical Scanning in Go - Rob Pike - YouTube -
http://www.youtube.com/watch?v=HxaD_trXwRE
   - http://golang.org/src/pkg/text/template/parse/lex.go

I modified it to use io.Reader instead of string as the input to the lexer.
I think it is better because whole input does not have to be on memory.

Feedbacks are welcome.

Cheers,
Hiroaki

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Andrew Gerrand at Sep 25, 2013 at 1:17 am

    On 25 September 2013 10:31, Hiroaki Nakamura wrote:

    - trim comments

    JSON can have comments?!

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Hiroaki Nakamura at Sep 25, 2013 at 2:04 am
    Hi Andrew.

    No, JSON cannot have comments.

    However, we would like to add comments to JSON in documents.
    This is why I created this pre-processor.

    It trims comment in "JSON" and outputs the valid JSON.



    2013/9/25 Andrew Gerrand <adg@golang.org>
    On 25 September 2013 10:31, Hiroaki Nakamura wrote:

    - trim comments

    JSON can have comments?!


    --
    中村 弘輝 )Hiroaki Nakamura)

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Andrew Gerrand at Sep 25, 2013 at 2:10 am
    You might want to add some documentation to README.md or the jsonpreprocess
    package comment that describes the acceptable comment syntax.

    On 25 September 2013 12:04, Hiroaki Nakamura wrote:

    Hi Andrew.

    No, JSON cannot have comments.

    However, we would like to add comments to JSON in documents.
    This is why I created this pre-processor.

    It trims comment in "JSON" and outputs the valid JSON.



    2013/9/25 Andrew Gerrand <adg@golang.org>
    On 25 September 2013 10:31, Hiroaki Nakamura wrote:

    - trim comments

    JSON can have comments?!


    --
    中村 弘輝 )Hiroaki Nakamura)
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Hiroaki Nakamura at Sep 26, 2013 at 12:25 am
    Hi, Andrew.

    Thanks for your feedback.
    I added some documentation to README.md about comment syntax.


    2013/9/25 Andrew Gerrand <adg@golang.org>
    You might want to add some documentation to README.md or the
    jsonpreprocess package comment that describes the acceptable comment syntax.

    On 25 September 2013 12:04, Hiroaki Nakamura wrote:

    Hi Andrew.

    No, JSON cannot have comments.

    However, we would like to add comments to JSON in documents.
    This is why I created this pre-processor.

    It trims comment in "JSON" and outputs the valid JSON.



    2013/9/25 Andrew Gerrand <adg@golang.org>
    On 25 September 2013 10:31, Hiroaki Nakamura wrote:

    - trim comments

    JSON can have comments?!


    --
    中村 弘輝 )Hiroaki Nakamura)

    --
    中村 弘輝 )Hiroaki Nakamura)

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Mattn at Sep 26, 2013 at 2:35 am
    Andrew, Do you have plan to add method SkipEmpty that overwritable to json
    Decoder?
    jd := json.NewDecoder(os.Stdin)
    jd.SkipEmpty = func(scan scan.Scanner) {
       // skip whitespace or C/C++ like comment syntaxs.
       ...
    }
    id.Decode(value)
    On Wednesday, September 25, 2013 11:09:41 AM UTC+9, Andrew Gerrand wrote:

    You might want to add some documentation to README.md or the
    jsonpreprocess package comment that describes the acceptable comment syntax.


    On 25 September 2013 12:04, Hiroaki Nakamura <hnak...@gmail.com<javascript:>
    wrote:
    Hi Andrew.

    No, JSON cannot have comments.

    However, we would like to add comments to JSON in documents.
    This is why I created this pre-processor.

    It trims comment in "JSON" and outputs the valid JSON.



    2013/9/25 Andrew Gerrand <a...@golang.org <javascript:>>
    On 25 September 2013 10:31, Hiroaki Nakamura <hnak...@gmail.com<javascript:>
    wrote:
    - trim comments

    JSON can have comments?!


    --
    中村 弘輝 )Hiroaki Nakamura)
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Andrew Gerrand at Sep 27, 2013 at 1:33 am

    On 26 September 2013 12:35, mattn wrote:

    Andrew, Do you have plan to add method SkipEmpty that overwritable to json
    Decoder?

    Nope, there are no plans to do this.

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Peter Bourgon at Sep 25, 2013 at 1:53 pm

    On 25 September 2013 10:31, Hiroaki Nakamura wrote:
    - trim comments
    JSON can have comments?!
    Sure.

    http://play.golang.org/p/WrkmWeaGmP

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Jens Alfke at Sep 27, 2013 at 1:27 am
    This looks very useful!

    One feature I'd like to see, that we currently do in a hacky way: a variant
    string syntax that allows double-quotes, backslashes and newlines within
    it. (Our syntax uses a back-quote as the delimiter, and converts everything
    up to the next back-quote into a regular JSON string, inserting escapes.)

    This is very useful if you need to embed JavaScript source code in a JSON
    document, which very often happens in CouchDB "design documents" and also
    in the configuration documents for the Couchbase Sync Gateway I'm working
    on. In regular JSON, the JavaScript usually turns into a mess of
    backslashes all glommed onto a single line.

    I'd love it if we could use your preprocessor instead of our current
    regex-based hack.

    --Jens

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedSep 25, '13 at 12:31a
activeSep 27, '13 at 1:33a
posts9
users5
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase