[Lift] Re: lift-json serialization

2010-02-08 Thread Joni Freeman
Hi, Serialization feature is actually a very thin layer on top of decompose and extract functions. So, one way to accomplish that is to use directly those functions and map the field names. So, instead of this: write(x, out) Try this: val json = decompose(x) map { case JField("firstname", x)

[Lift] Re: lift-Json doesn't appear to be correctly handling attributes.

2010-02-04 Thread Joni Freeman
Thanks, The fix is on review board now. Should be in master pretty soon. Note, I made two changes to the test case you provided. The expected result of example1 is: {"word":"content","self":"http://localhost:8080/word/ example","term":"example","available":"true"} The transformation converts XML

Re: [Lift] Re: lift-Json doesn't appear to be correctly handling attributes.

2010-02-03 Thread Jonathan Ferguson
Thanks Joni, I've opened a ticket http://github.com/dpp/liftweb/issues/issue/323. Cheers Jono On 3 February 2010 17:46, Joni Freeman wrote: > Hi Jonathan, > > Yes, definitely a bug. Could you please open a ticket (http:// > github.com/dpp/liftweb/issues) and I will take a look at it. And > th

[Lift] Re: lift-Json doesn't appear to be correctly handling attributes.

2010-02-02 Thread Joni Freeman
Hi Jonathan, Yes, definitely a bug. Could you please open a ticket (http:// github.com/dpp/liftweb/issues) and I will take a look at it. And thanks for the test case! Cheers Joni On Feb 3, 3:41 am, Jonathan Ferguson wrote: > When converting XML to Json attributes are being lost, given the below

[Lift] Re: lift-json and illegal field names

2009-12-10 Thread harryh
Thx all! Just couldn't remember that little trick. -harryh -- You received this message because you are subscribed to the Google Groups "Lift" group. To post to this group, send email to lift...@googlegroups.com. To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.c

Re: [Lift] Re: lift-json escaping bug

2009-12-01 Thread Ross Mellgren
Fixed: d977c95589fbd5de8bc45e43c2867097dd75a807 -Ross On Nov 30, 2009, at 8:33 PM, harryh wrote: > Done: > > http://github.com/dpp/liftweb/issues/#issue/214 > > On Nov 30, 6:33 pm, Ross Mellgren wrote: >> If you file an issue on github I'll write up a patch for you tonight. >> >> -Ross >>

[Lift] Re: lift-json escaping bug

2009-11-30 Thread Joni Freeman
Hi, This is from JSON RFC (http://www.ietf.org/rfc/rfc4627.txt): "A JSON text is a serialized object or array." I checked with another parser (http://www.jsonlint.com) and it fails too when given just JSON value: "syntax error, unexpected TNUMBER, expecting '{' or '[' at line 1" So perhaps a bet

Re: [Lift] Re: lift-json escaping bug

2009-11-30 Thread Ross Mellgren
On review board: http://reviewboard.liftweb.net/r/131/ I did run across another infelicity when writing the test -- apparently JsonParser crashes when given a scalar value, as opposed to an array or object: scala> parse("\"foobar\"") net.liftweb.json.JsonParser$ParseException: unexpected null Ne

[Lift] Re: lift-json escaping bug

2009-11-30 Thread harryh
Done: http://github.com/dpp/liftweb/issues/#issue/214 On Nov 30, 6:33 pm, Ross Mellgren wrote: > If you file an issue on github I'll write up a patch for you tonight. > > -Ross > > On Nov 30, 2009, at 6:30 PM, harryh wrote: > > > Yes, what Ross said.  Further, taking a look at JsonParser.scala t

Re: [Lift] Re: lift-json escaping bug

2009-11-30 Thread Ross Mellgren
What I find particularly interesting is that the JSON spec lacks \', but gains \/, relative to the ECMA-262 (javascript) spec that JSON supposedly derives from. -Ross On Nov 30, 2009, at 6:34 PM, Nathan Folkman (Foursquare) wrote: > Here's the complete list from http://json.org/: > > char: >

[Lift] Re: lift-json escaping bug

2009-11-30 Thread Nathan Folkman (Foursquare)
Here's the complete list from http://json.org/: char: Any Unicode character except " or \ or control-character. \" \\ \/ \b \f \n \r \t \u four-hex-digits - n On Nov 30, 6:30 pm, harryh wrote: > Yes, what Ross said.  Further, taking a look at JsonParser.scala the > bug appears to be on line ~

Re: [Lift] Re: lift-json escaping bug

2009-11-30 Thread Ross Mellgren
If you file an issue on github I'll write up a patch for you tonight. -Ross On Nov 30, 2009, at 6:30 PM, harryh wrote: > Yes, what Ross said. Further, taking a look at JsonParser.scala the > bug appears to be on line ~202 where there are a couple of missing > escape sequences: \/ as well as \f.

[Lift] Re: lift-json escaping bug

2009-11-30 Thread harryh
Yes, what Ross said. Further, taking a look at JsonParser.scala the bug appears to be on line ~202 where there are a couple of missing escape sequences: \/ as well as \f. -harryh On Nov 30, 6:20 pm, Ross Mellgren wrote: > He's double escaping so that scala's string interpretation will put a   >

Re: [Lift] Re: lift-json escaping bug

2009-11-30 Thread Ross Mellgren
He's double escaping so that scala's string interpretation will put a raw \ in there, so that it's an escaped forward slash (\/) to the JSON parson, as I understand it. The output should be either invalid escape or forward slash, but not backslash unless the input was \\. -Ross On Nov 30, 2

[Lift] Re: lift-json escaping bug

2009-11-30 Thread Peter Robinett
Harry, I think you're double-escaping the slash. This works: scala> import net.liftweb.json._ scala> val s1 = "{ \"id\": \"America/New_York\" }" s1: java.lang.String = { "id": "America/New_York" } scala> JsonParser.parse(s1) res0: net.liftweb.json.JsonAST.JValue = JObject(List(JField(id,JString (A

[Lift] Re: lift-json question related to Lists of things

2009-11-25 Thread Joni Freeman
Hi, Totally agreed, this makes List extraction more robust. The change is in reviewboard now: http://reviewboard.liftweb.net/r/127/ Cheers Joni On 25 marras, 20:42, harryh wrote: > consider: > > case class Foo(id: Int, bars: List[Bar]) > case class Bar(id: Int) > > val foo = json.extract[Foo]

[Lift] Re: lift-json bug (in Xml.toJson)

2009-11-11 Thread David Pollak
I think a fix to this was pushed this morning. Once this job is finished: http://hudson.scala-tools.org/job/Lift/1367/ It should be available on SNAPSHOT. On Tue, Nov 10, 2009 at 1:49 PM, harryh wrote: > > This is on M7: > > scala> import > scala.xml.Elem > import scala.xml.Elem > > scala> imp

[Lift] Re: lift-json serialization primitive types

2009-11-02 Thread Joni Freeman
Hi, Custom serialization and deserialization functions are now supported in trunk. Please see updated docs in section "Serializing non- supported types": http://github.com/dpp/liftweb/tree/master/lift-base/lift-json/ Cheers Joni On 25 loka, 14:27, Christophe Dehlinger wrote: > Hi, > > Is the

[Lift] Re: lift-json serialization primitive types

2009-10-25 Thread Joni Freeman
Hi, Serializing joda-time is not supported. Last week a type hint mechanism was added to support serialization of polymorphic Lists. This could be generalized a bit so that users can provide de-/ serializers for any type. This could be done for instance using a pair of partial functions. Somethin

[Lift] Re: lift-json and attributes

2009-10-07 Thread Richard Dallaway
On Mon, Oct 5, 2009 at 9:01 PM, Joni Freeman wrote: > > Thanks Richard! > > This is a feature request and I just committed an implementation to my > branch. I've just pulled 1-1 SNAPSHOT, tried it, and it works just how I need it to. Thank you Richard --~--~-~--~~~-

[Lift] Re: lift-json and attributes

2009-10-06 Thread David Pollak
On Tue, Oct 6, 2009 at 9:03 AM, harryh wrote: > > > This is a feature request and I just committed an implementation to my > > branch. > > This looks great. If there is anyway it could get committed to master > in time for M6 (which is coming out any day now right?) that would be > very very hel

[Lift] Re: lift-json and attributes

2009-10-06 Thread harryh
> This is a feature request and I just committed an implementation to my > branch. This looks great. If there is anyway it could get committed to master in time for M6 (which is coming out any day now right?) that would be very very helpful to me. Thanks for your work on this stuff Joni! -harr

[Lift] Re: lift-json and attributes

2009-10-05 Thread Joni Freeman
Thanks Richard! This is a feature request and I just committed an implementation to my branch. I modified existing example to contain few attributes to show how they are mapped: http://github.com/dpp/liftweb/blob/joni_wip_xml/lift-json/src/test/scala/net/liftweb/json/XmlExamples.scala If other

[Lift] Re: lift-json serialization

2009-09-24 Thread Tim Nelson
Excellent. Thanks. On Thu, Sep 24, 2009 at 2:21 AM, Joni Freeman wrote: > > Tim, > > Extracted function is now in master. I renamed it as 'decompose' since > it decomposes case class into JSON AST. > > Thanks again, Joni > > On Sep 21, 6:52 pm, Tim Nelson wrote: > > First of all thanks for a gre

[Lift] Re: lift-json serialization

2009-09-24 Thread Joni Freeman
Tim, Extracted function is now in master. I renamed it as 'decompose' since it decomposes case class into JSON AST. Thanks again, Joni On Sep 21, 6:52 pm, Tim Nelson wrote: > First of all thanks for a great library. I'm finding lift-json quite useful > in my current project. > > I have a use c

[Lift] Re: lift-json serialization

2009-09-21 Thread Joni Freeman
Oh, I see the point now and agree that this is useful. Let's add thia to API. Thanks a lot! Cheers Joni On Sep 21, 6:52 pm, Tim Nelson wrote: > First of all thanks for a great library. I'm finding lift-json quite useful > in my current project. > > I have a use case where I need to convert a ca

[Lift] Re: lift-json serialization

2009-09-21 Thread Joni Freeman
Hi Tim, Thanks for the kind words! The serialization functions should already be publicly accessible, you just need to import them into scope: import net.liftweb.json.Serialization.{read, write} val ser = write(...) val obj = read[..](ser) Cheers Joni On Sep 21, 6:52 pm, Tim Nelson wrote: >

[Lift] Re: lift-json

2009-09-13 Thread Lincoln
Got it. Thanks for the info. I was afraid I was doing something wrong. Thanks, Lincoln On Sun, Sep 13, 2009 at 9:48 AM, Joni Freeman wrote: > > Hi, > > Your example should work if you take the val away from your case > class: > > case class MyName(first:String, last:String) > case class MyUser(

[Lift] Re: lift-json

2009-09-13 Thread Joni Freeman
Hi, Your example should work if you take the val away from your case class: case class MyName(first:String, last:String) case class MyUser(id:String, name:MyName, url:String) The reflection code currently fails to find the primary constructor of case class if there's extra fields. This will hop

[Lift] Re: lift-json

2009-09-13 Thread Lincoln
Sorry, here's the full code I'm using: case class MyName(first:String, last:String) case class MyUser(id:String, name:MyName, url:String) { val wtf = "wtf" } implicit val formats = net.liftweb.json.DefaultFormats val json = ("id" -> me.id) ~ ("name" -> ("first" -> me.name.first) ~ ("last" -> me