Ok, added. This is a quick hack just to explore the problem so expect
bugs, holes in logic and such.

Example usage:
http://github.com/dpp/liftweb/blob/f974b41c56afa500e9d93371f0ce21bde3c854ce/lift-json/src/test/scala/net/liftweb/json/XmlExamples.scala

Cheers Joni


On Sep 3, 2:40 am, David Pollak <feeder.of.the.be...@gmail.com> wrote:
> Cool... I'd be interested in you pushing this to master and letting people
> use it and give feedback.
>
>
>
> On Wed, Sep 2, 2009 at 2:40 PM, Joni Freeman <freeman.j...@gmail.com> wrote:
>
> > Hi,
>
> > I just quickly spiked this and following works on my local branch:
>
> > scala> val xml =
> >   <foos>
> >    <foo>
> >      <id>1</id>
> >      <name>Harry</name>
> >    </foo>
> >    <foo>
> >      <id>2</id>
> >      <name>David</name>
> >    </foo>
> >  </foos>
>
> > scala> val json = toJson(xml)
> > scala> compact(render(json))
> > {"foos":{"foo":[{"id":"1","name":"Harry"},{"id":"2","name":"David"}]}}
>
> > scala> val json2 = json map {
> >         case JField("id", JString(s)) => JField("id", JInt(s.toInt))
> >         case x => x
> >       }
> > scala> compact(render(json2))
> > {"foos":{"foo":[{"id":1,"name":"Harry"},{"id":2,"name":"David"}]}}
>
> > This could be quite useful addition. However, I have at least one
> > concern. What kind of processing instructions will eventually be
> > needed for this to be generic enough? For instance, lets change the
> > example XML to:
>
> >  <foos>
> >    <foo>
> >       <id>1</id>
> >      <name>Harry</name>
> >    </foo>
> >   </foos>
>
> > This would still be valid when validating against original XML's DTD,
> > but the generated JSON structure would be something quite different
> > (no arrays):
> > {"foos":{"foo":{"id":1,"name":"Harry"}}}
>
> > Cheers Joni
>
> --
> Lift, the simply functional web frameworkhttp://liftweb.net
> Beginning Scalahttp://www.apress.com/book/view/1430219890
> Follow me:http://twitter.com/dpp
> Git some:http://github.com/dpp
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to liftweb@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
-~----------~----~----~----~------~----~------~--~---

Reply via email to