Thank you both for your explanations it seems assigning val Observation to Observe is a bad idea, what should I do to get the parced information to the Observation map?
On Jan 15, 8:42 am, Ross Mellgren <dri...@gmail.com> wrote: > Isn't it that the val Observation is being assigned to the (compiler > synthesized) Observe singleton object? In either case, no save method. > > -Ross > > On Jan 14, 2010, at 4:41 PM, David Pollak wrote: > > > > > On Thu, Jan 14, 2010 at 1:37 PM, Randinn <rand...@gmail.com> wrote: > > Well here is the latest iteration of the code: > > >http://paste.pocoo.org/show/165511/ > > > but I'm getting this error > > > Compiling 11 source files to C:\Users\Randin\Documents\Development > > \weather\target\classes at 1263504637934 > > [ERROR]weather/snippet/HelloWorld.scala:32: error: value save is not a > > member of object HelloWorld.this.Observe > > Observation.save > > > The Observation method is returning an instance of the Observe case class. > > This class has no "save" method on it, thus the error. > > > ^ > > [ERROR]one error found > > > I went to 2.0-M1 and did a clean install. I assume save might be the > > answer, how close am I? > > > On Jan 4, 1:00 am, Joni Freeman <freeman.j...@gmail.com> wrote: > > > Google Groups does not shine in formatting code snippets. Here's nicer > > > version: > > > >http://paste.pocoo.org/show/161578/ > > > > Cheers Joni > > > > On 3 tammi, 12:20, Joni Freeman <freeman.j...@gmail.com> wrote: > > > > > Hi, > > > > > That's almost correct. I did following changes after looking into JSON > > > > content. > > > > > 1. 'notice' and 'header' are JSON arrays just like 'data'. Therefore: > > > > case class Observation(notice: List[Notice], header: List[Header], > > > > data: List[Data]) > > > > > 2. There's optional data in JSON (some datapoints are nulls and Scala > > > > Int or Double can't take null values). This can be fixed by extracting > > > > into Option. > > > > > 3. The extracted Observation is in JSON field 'observations'. > > > > Therefore: > > > > (json \ "observations").extract[Observation] > > > > > Your error stack trace suggests that you have an old version of lift- > > > > json. Please upgrade to M8, there was a critical bug in case class > > > > extraction in older versions. > > > > > Full example which works for me: > > > > > implicit val formats = net.liftweb.json.DefaultFormats > > > > case class Notice(copyright: String, copyright_url: String, > > > > disclaimer_url: String) > > > > case class Header(refresh_message: String, ID: String, main_ID: > > > > String, name: String, state_time_zone: String, time_zone: String, > > > > product_name: String, state: String) > > > > case class Data(sort_order: Int, wmo: Int, history_product: String, > > > > local_date_time: String, > > > > local_date_time_full: String, air_temp: Option > > > > [Double], dewpt: Option[Double], apparent_t: Option[Double], > > > > rel_hum: Option[Int], delta_t: Option[Double], > > > > wind_dir: String, wind_spd_kt: Option[Double], gust_kt: Option > > > > [Double], > > > > wind_spd_kmh: Option[Double], press: Option[Double], > > > > rain_trace: String) > > > > > case class Observation(notice: List[Notice], header: List[Header], > > > > data: List[Data]) > > > > > (json \ "observations").extract[Observation] > > > > > Cheers Joni > > > > > On 3 tammi, 09:17, Randinn <rand...@gmail.com> wrote: > > > > > > I'm having a bit of trouble with Lift Json parcing, I know I'm not > > > > > doing it correctly but looking at the examples I cannot figure out > > > > > what, anyway, here is the code in question..... If someone could point > > > > > me in the right direction that would be great, thanks in advance. > > > > > > class HelloWorld { > > > > > def howdy = <span>Welcome to hello-lift at {new > > > > > _root_.java.util.Date}</span> > > > > > val http = new Http > > > > > val bos = new ByteArrayOutputStream > > > > > val myRequest = new Request("http://www.bom.gov.au/fwo/IDV60901/ > > > > > IDV60901.94868.json") > > > > > val rawdata = http(myRequest >>> bos) > > > > > val bs = bos.toString > > > > > val db = :/("www.bom.gov.au") > > > > > > val json = parse(bs) > > > > > > implicit val formats = net.liftweb.json.DefaultFormats > > > > > case class Notice(copyright: String, copyright_url: String, > > > > > disclaimer_url: String) > > > > > case class Header(refresh_message: String, ID: String, main_ID: > > > > > String, name: String, state_time_zone: String, > > > > > time_zone: String, product_name: String, state: > > > > > String) > > > > > case class Data(sort_order: Int, wmo: Int, history_product: String, > > > > > local_date_time: String, > > > > > local_date_time_full: Int, air_temp: Double, dewpt: > > > > > Double, apparent_t: Double, > > > > > rel_hum: Double, delta_t: Double, wind_dir: Double, > > > > > wind_spd_kt: Double, gust_kt: Double, > > > > > wind_spd_kmh: Double, press: Double, rain_trace: > > > > > Double) > > > > > case class Observation(notice: Notice, header: Header, data: List > > > > > [Data]) > > > > > json.extract[Observation] > > > -- > > 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.com. > > For more options, visit this group > > athttp://groups.google.com/group/liftweb?hl=en. > > > -- > > Lift, the simply functional web frameworkhttp://liftweb.net > > Beginning Scalahttp://www.apress.com/book/view/1430219890 > > Follow me:http://twitter.com/dpp > > Surf the harmonics > > -- > > 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.com. > > For more options, visit this group > > athttp://groups.google.com/group/liftweb?hl=en. > >
-- 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.com. For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.