Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
[2.1 master] Please help with Json.reads Json.writes macros
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  Messages 26 - 43 of 43 - Collapse all  -  Translate all to Translated (View all originals) < Older 
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Daniel Dietrich  
View profile  
 More options Nov 18 2012, 8:36 pm
From: Daniel Dietrich <cafeb...@googlemail.com>
Date: Sun, 18 Nov 2012 17:36:38 -0800 (PST)
Local: Sun, Nov 18 2012 8:36 pm
Subject: Re: [play-framework] [2.1 master] Please help with Json.reads Json.writes macros

[a little bit off topic]

Pascal,

I'm working on a generic DAO abstraction layer for Slick w/ Play and took
the chance to create my first Scala macro :)

Unfortunately I'm stuck at 99,9% of the macro, where a method with a named
parameter has to be called via macro.

If you are interested:

http://stackoverflow.com/questions/13446528/howto-model-named-paramet...

Regards

- Daniel


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Pascal Voitot Dev  
View profile  
 More options Nov 19 2012, 3:16 am
From: Pascal Voitot Dev <pascal.voitot....@gmail.com>
Date: Mon, 19 Nov 2012 09:16:01 +0100
Local: Mon, Nov 19 2012 3:16 am
Subject: Re: [play-framework] [2.1 master] Please help with Json.reads Json.writes macros

I'll think about it... instead of using copy, you could also try to use
constructor directly in the macro...

But just one point: be really careful when you choose macro instead of a
classic language pattern. I really consider macro as a tool but not as a
patch to solve problems that shouldn't be solved in this way... (I don't
say your choice is bad, just to consider macros very precisely ;) )

regards
Pascal

On Mon, Nov 19, 2012 at 2:36 AM, Daniel Dietrich <cafeb...@googlemail.com>wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Daniel Dietrich  
View profile  
 More options Nov 19 2012, 11:13 am
From: Daniel Dietrich <cafeb...@googlemail.com>
Date: Mon, 19 Nov 2012 08:13:29 -0800 (PST)
Local: Mon, Nov 19 2012 11:13 am
Subject: Re: [play-framework] [2.1 master] Please help with Json.reads Json.writes macros

Thank you. It was very interesting to investigate the new Scala macros &
reflection features. I see also the pros/cons of changing the default
behavior of the compiler - and with that the semantics of the Scala
language. One important thing of Scala is its conciseness. With macros
things can be done even more concise. That was also my driver in this case.
I'm curious if folks will create a Scala_A, Scala_B, ... in the near future
- à la 'pimp my language'...

greets
Daniel


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jay  
View profile  
 More options Nov 23 2012, 9:49 pm
From: Jay <cain....@gmail.com>
Date: Fri, 23 Nov 2012 18:49:26 -0800 (PST)
Local: Fri, Nov 23 2012 9:49 pm
Subject: Re: [play-framework] [2.1 master] Please help with Json.reads Json.writes macros

I'm having issues with using the new json libs.  I wrote the following spec

import play.api.test._
import play.api.test.Helpers._
import play.api.libs.json.Json

import models._
import json.JsonFormats._

class JsonFormatsSpec extends Specification {

  "JsonFormats" should {

    "equals the user jay" in {
      val profile = Profile("Jay Cain")

      val settings = Settings()

      val jay = User("cain....@gmail.com", profile, settings, "hash", None,
false)

      val userJson = Json.toJson(jay)  

      val user = Json.fromJson(userJson)
      ...
    }

  }

}

when I run the test I get the following error:

[error] /Users/cainj/sandbox/pong/test/json/ApplicationSpec.scala:30:
diverging implicit expansion for type play.api.libs.json.Reads[T]
[error] starting with method ArrayReads in trait DefaultReads
[error]       val user = Json.fromJson(userJson)
[error]                               ^

Any insight would be helpful.  I'm tried the play master and play-2.1-RC-1

Thx,

Jay


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jay  
View profile  
 More options Nov 23 2012, 11:33 pm
From: Jay <cain....@gmail.com>
Date: Fri, 23 Nov 2012 20:33:52 -0800 (PST)
Local: Fri, Nov 23 2012 11:33 pm
Subject: Re: [play-framework] [2.1 master] Please help with Json.reads Json.writes macros

I just looked at the quote above more closely, I need to clone  git://
github.com/mandubian/Play20.git


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Daniel Dietrich  
View profile  
 More options Nov 24 2012, 1:43 am
From: Daniel Dietrich <cafeb...@googlemail.com>
Date: Fri, 23 Nov 2012 22:43:57 -0800 (PST)
Local: Sat, Nov 24 2012 1:43 am
Subject: Re: [play-framework] [2.1 master] Please help with Json.reads Json.writes macros

Hi Jay,

it should work with the 2.1 master / rc1 too. Just add these imports and to implicit val's:

Anyway, as of this discussion the json stuff is currently subject of refactoring...

import play.api.libs.json._
import play.api.libs.json.util._
// import play.api.libs.json.Reads._
import play.api.libs.json.Writes._

  implicit val userReads = Json.reads[User]
  implicit val userWrites = Json.writes[User]

There's a pending pull request which reduces the imports to the minimum...

- Daniel


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Cristi Boariu  
View profile  
 More options Nov 26 2012, 11:27 am
From: Cristi Boariu <cristiboa...@gmail.com>
Date: Mon, 26 Nov 2012 08:27:15 -0800 (PST)
Local: Mon, Nov 26 2012 11:27 am
Subject: Re: [play-framework] [2.1 master] Please help with Json.reads Json.writes macros

Hi Daniel,

I used your latest imports (whithout Read) but I receive the same warnings
similar to you, my code is:

import play.api.libs.json._
import play.api.libs.json.util._
import play.api.libs.json.Writes._

object AddressBean extends Controller with RestTrait {

  implicit val addressWrites = Json.writes[Address]

  implicit val addressReads = Json.reads[Address]

}

warning: value and is not a member of play.api.libs.json.Reads[Option[Int]]
Note: implicit value addressReads is not
 applicable here because it comes after the application point and it lacks
an explicit result type

I'm wondering if you have added anything else to fix these...

Basically I have to make this JSON stuff to work with 2.1-RC1 because my
project uses scala 2.10 so can't go back to 2.09... Is there any chance to
solve this issue?

Thanks!


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Pascal Voitot Dev  
View profile  
 More options Nov 26 2012, 11:35 am
From: Pascal Voitot Dev <pascal.voitot....@gmail.com>
Date: Mon, 26 Nov 2012 17:34:35 +0100
Local: Mon, Nov 26 2012 11:34 am
Subject: Re: [play-framework] [2.1 master] Please help with Json.reads Json.writes macros

Please try this
import play.api.libs.functional.syntax._

instead of
import play.api.libs.json.util._

(the package has been moved just before releasing RC1)
(FYI in master this import is no more required as well as Writes._)

regards
Pascal

On Mon, Nov 26, 2012 at 5:27 PM, Cristi Boariu <cristiboa...@gmail.com>wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Cristi Boariu  
View profile  
 More options Nov 26 2012, 11:36 am
From: Cristi Boariu <cristiboa...@gmail.com>
Date: Mon, 26 Nov 2012 08:36:08 -0800 (PST)
Local: Mon, Nov 26 2012 11:36 am
Subject: Re: [play-framework] [2.1 master] Please help with Json.reads Json.writes macros

Wow, it works, thanks.......


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Thibault  
View profile  
 More options Nov 30 2012, 1:03 pm
From: Thibault <thibault.duples...@gmail.com>
Date: Fri, 30 Nov 2012 10:03:31 -0800 (PST)
Local: Fri, Nov 30 2012 1:03 pm
Subject: Re: [play-framework] [2.1 master] Please help with Json.reads Json.writes macros

I'm getting a compiler error when the case class has a companion object. I
use scala 2.10.0-RC3 and the very latest Play20, built from master branch.

Here is a quick gist to reproduce the problem:
https://gist.github.com/4177343

Excellent job with Play 2.1, thanks a bunch! I'm now rewritting
http://lichess.org with all that new goodness, it's a lot of fun.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Thibault  
View profile  
 More options Nov 30 2012, 1:21 pm
From: Thibault <thibault.duples...@gmail.com>
Date: Fri, 30 Nov 2012 10:21:48 -0800 (PST)
Local: Fri, Nov 30 2012 1:21 pm
Subject: Re: [play-framework] [2.1 master] Please help with Json.reads Json.writes macros

Interrestingly enouth, I get the same error when I do the mapping manually,
without using the macro magic! See that gist https://gist.github.com/4177529

I'm sure there is a better solution than renaming all my companion objects
;) But what could it be?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Pascal Voitot Dev  
View profile  
 More options Nov 30 2012, 1:29 pm
From: Pascal Voitot Dev <pascal.voitot....@gmail.com>
Date: Fri, 30 Nov 2012 19:29:04 +0100
Local: Fri, Nov 30 2012 1:29 pm
Subject: Re: [play-framework] [2.1 master] Please help with Json.reads Json.writes macros

Hi
Did you have same for problem with Scala 2.10RC2 ?

Pascal
Le 30 nov. 2012 19:03, "Thibault" <thibault.duples...@gmail.com> a écrit :


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Pascal Voitot Dev  
View profile  
 More options Nov 30 2012, 6:15 pm
From: Pascal Voitot Dev <pascal.voitot....@gmail.com>
Date: Sat, 1 Dec 2012 00:15:41 +0100
Local: Fri, Nov 30 2012 6:15 pm
Subject: Re: [play-framework] [2.1 master] Please help with Json.reads Json.writes macros

If you use Foo.apply, it should work.

As soon as you create object for case class, case class hidden features are
overriden by compiler...
Concerning the macro, I think we could improve it a bit and go around this
problem.

Pascal
Le 30 nov. 2012 19:22, "Thibault" <thibault.duples...@gmail.com> a écrit :


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Thibault  
View profile  
 More options Dec 1 2012, 12:04 pm
From: Thibault <thibault.duples...@gmail.com>
Date: Sat, 1 Dec 2012 09:04:20 -0800 (PST)
Local: Sat, Dec 1 2012 12:04 pm
Subject: Re: [play-framework] [2.1 master] Please help with Json.reads Json.writes macros

Indeed manual mapping with (Foo.apply _) is working.

I tried the macro style with scala 2.10.0-RC2, and no difference, I get the
same compiler error.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Grégory Bougeard  
View profile  
 More options Dec 1 2012, 6:35 pm
From: Grégory Bougeard <gbouge...@gmail.com>
Date: Sat, 1 Dec 2012 15:35:59 -0800 (PST)
Local: Sat, Dec 1 2012 6:35 pm
Subject: Re: [play-framework] [2.1 master] Please help with Json.reads Json.writes macros

As @mandubian told me, there is a limitation on case class containing one
and only one attribute.
Maybe this is your case...

Le samedi 1 décembre 2012 18:04:20 UTC+1, Thibault a écrit :


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Thibault  
View profile  
 More options Dec 3 2012, 3:57 pm
From: Thibault <thibault.duples...@gmail.com>
Date: Mon, 3 Dec 2012 12:57:58 -0800 (PST)
Local: Mon, Dec 3 2012 3:57 pm
Subject: Re: [play-framework] [2.1 master] Please help with Json.reads Json.writes macros

No it's the same thing with several attributes. Sorry for the delay, I'm
travelling at the moment.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
deVIAntCoDE  
View profile  
 More options Jan 3, 9:35 am
From: deVIAntCoDE <hnoclel...@gmail.com>
Date: Thu, 3 Jan 2013 06:35:56 -0800 (PST)
Local: Thurs, Jan 3 2013 9:35 am
Subject: Re: [play-framework] [2.1 master] Please help with Json.reads Json.writes macros

Yes I have the same problem as well. I have had to rename my companion
objects as well. What is the progress on the issue though?
I found this ticket relating to it but no comment on it so far.
https://play.lighthouseapp.com/projects/82401/tickets/887-adding-a-co...


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Pascal Voitot Dev  
View profile  
 More options Jan 3, 9:37 am
From: Pascal Voitot Dev <pascal.voitot....@gmail.com>
Date: Thu, 3 Jan 2013 15:37:55 +0100
Local: Thurs, Jan 3 2013 9:37 am
Subject: Re: [play-framework] [2.1 master] Please help with Json.reads Json.writes macros

I haven't tested with latest scala 2.10.0 but it might be a problem in
Scala directly...

pascal


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages < Older 
« Back to Discussions « Newer topic     Older topic »