David Linsin wrote:
> Hi there,
>
> how would I fetch a remote json representation of a resource on the
> web, using liftweb? Let's say my twitters at
> http://twitter.com/statuses/user_timeline/dlinsin.json.
>
lift does the HTTP server side of things. Scala has built-in support
for what you're looking for:
import scala.io.Source
import scala.util.parsing.json.JSON
val s =
Source.fromURL("http://twitter.com/statuses/user_timeline/dlinsin.json")
JSON.parseFull(s.mkString(""))
You thinking about using lift to do a front-end to Twitter?
Thanks for your help!
Not really, I'm just playing around with liftweb, trying to touch
> You thinking about using lift to do a front-end to Twitter?
every part of the framework. I simply extend the generated lift
project to have a new site where you can check yours/your friends
twitters. Being a complete newbie considering liftweb and scala it'll
help me getting started. Maybe I'll document the steps and make it a
tutorial.
On Mar 14, 12:39 am, David Pollak <d...@athena.com> wrote:
> David Linsin wrote:
> > Hi there,
>
> > how would I fetch a remote json representation of a resource on the
> > web, using liftweb? Let's say my twitters at
> >http://twitter.com/statuses/user_timeline/dlinsin.json.
>
> lift does the HTTP server side of things. Scala has built-in support
> for what you're looking for:
> import scala.io.Source
> import scala.util.parsing.json.JSON
>
> val s =
> Source.fromURL("http://twitter.com/statuses/user_timeline/dlinsin.json")
> JSON.parseFull(s.mkString(""))
>
> You thinking about using lift to do a front-end to Twitter?
>
> > Thanks for your help
>
> > regards, David
--j "oh no..."
type DavidP = Documentation => Beverage[Choice] ?
>
> Hi David,
>
>> val s =
>> Source.fromURL("http://twitter.com/statuses/user_timeline/
>> dlinsin.json")
>> JSON.parseFull(s.mkString(""))
>
> the return value from JSON.parseFull is a List of Lists. The strange
> thing about this is, that the order of the elements in the List
> changes randomly. Sometimes it won't change for hours, then it
> suddenly changed and the code picking out items from the list fails
> due to index changes.
Interesting... although picking stuff out of a list by index is an O
(n) operation.
>
> Has anyone experienced something like that with JSON.parseFull?
No, but this is more of a Scala-users question than a lift question.
>
> Regards, David
>
> BTW: I don't think Twitter changes it's structure of the json data
> randomly
Actually, it's not unexpected (I have some pretty intimate knowledge
of Twitter's systems). If, for some reason, the cache that's serving
the items is flushed, the cache would be rebuilt and that would lead
to a re-ordering. Also, if you hit your hourly request limit, the
data will change.
The best thing to do is dump the text value retrieved from the each
request to a file and see if the data changes.
Thanks,
David
>
>
> On Mar 14, 7:39 am, David Pollak <d...@athena.com> wrote:
>> David Linsin wrote:
>>> Hi there,
>>
>>> how would I fetch a remote json representation of a resource on the
>>> web, using liftweb? Let's say my twitters at
>>> http://twitter.com/statuses/user_timeline/dlinsin.json.
>>
>> lift does the HTTP server side of things. Scala has built-in support
>> for what you're looking for:
>> import scala.io.Source
>> import scala.util.parsing.json.JSON
>>
>> val s =
>> Source.fromURL("http://twitter.com/statuses/user_timeline/
>> dlinsin.json")
>> JSON.parseFull(s.mkString(""))
>>
>> You thinking about using lift to do a front-end to Twitter?
>>
>>> Thanks for your help
>>
>>> regards, David
>
> >
--
David Pollak
http://blog.lostlake.org