« Return to Thread: [ANN] Literaljson 0.1

Re: [ANN] Literaljson 0.1

by Joni Freeman-2 :: Rate this Message:

Reply to Author | View in Thread

Hi Daniel,

I'm not sure if introducing Nil object would be enough. It isn't clear
where Nil object(s) should be inserted for instance in this example
case.

  ("person" ->
    ("name" -> "Joe") ~
    ("age" -> 35) ~
    ("spouse" ->
      ("person" ->
        ("name" -> "Marilyn") ~
        ("age" -> 33)
      )
    )
  )

Cheers Joni

On Thu, 2009-07-09 at 12:31 -0300, Daniel Sobral wrote:

> Oh, the trait thing is just an implicit import of implicits. :-) It
> forces the scope to be a class or object, though.
>
>
> The only suggestion I can think of is creating a JSON "Nil" json
> object, so that every json expression would be started like "JSON
> ~ ...", thus foregoing the need for an implicit. Naturally, "~" in
> object JSON would be defined as returning a json instance of the
> pair/list to it's right.
>
>
> Does that make sense? Do you feel it would overburden the syntax?
>
> On Thu, Jul 9, 2009 at 1:36 AM, Joni Freeman <joni.freeman@...>
> wrote:
>         I agree that such implicit conversions should preferably be
>         targeted for
>         more specific types. But I couldn't figure out any solution
>         without
>         sacrificing the readability of DSL. I'm open for any
>         suggestions, the
>         implementation is just a thin layer on top of AST and can be
>         tweaked
>         easily.
>        
>         The DSL is defined in object JsonDSL and needs to be imported
>         into
>         scope. Scala allows import statements in many places thus it
>         is already
>         possible to control the scope of those implicits (*). I'm not
>         sure what
>         would it buy to move the definitions inside a trait. Or am I
>         missing
>         something?
>        
>         (*)
>         object scopetest extends Application {
>          println("hello")
>        
>          {
>            import literaljson.JsonDSL._
>            val foo = ("foo" -> 1) ~ ("bar" -> 2)
>            println(foo)
>          }
>        
>          println("world")
>         }
>        
>        
>         Cheers Joni
>        
>        
>         On Wed, 2009-07-08 at 17:26 -0300, Daniel Sobral wrote:
>         > I'm not sure I like the implicit that adds "~" to Tuple2. I
>         think this
>         > kind of stuff should either require a domain-specific type,
>         or be
>         > defined inside a trait, so that it is easier to control it's
>         scope.
>         >
>         > On Wed, Jul 8, 2009 at 1:39 PM, Joni Freeman
>         <joni.freeman@...>
>         > wrote:
>         >         JSON toolkit for Scala
>         >
>         http://github.com/jonifreeman/literaljson/tree/master
>         >
>         >         Features:
>         >
>         >         * DSL to create JSON
>         >         * Quite fast parser, 200 times faster than standard
>         Scala JSON
>         >         parser
>         >         according to one benchmark:
>         >
>         http://github.com/jonifreeman/literaljson/tree/be575a9eda0f2cee75d2665ef48aa4abf601c06d/benchmark
>         >         * Compact formatting
>         >         * Pretty printing
>         >         * XPath like queries
>         >
>         >         Cheers, Joni
>         >
>         >
>         >
>         >
>         >
>         >
>         > --
>         > Daniel C. Sobral
>         >
>         > Something I learned in academia: there are three kinds of
>         academic
>         > reviews: review by name, review by reference and review by
>         value.
>        
>        
>
>
>
> --
> Daniel C. Sobral
>
> Something I learned in academia: there are three kinds of academic
> reviews: review by name, review by reference and review by value.
>

 « Return to Thread: [ANN] Literaljson 0.1