[Lift] Re: XML -> JSON converter?
This is really great, making XML as easy to generate as JSON was something I thought I'd never see. On Fri, Sep 25, 2009 at 7:27 AM, David Pollak wrote: > > > On Fri, Sep 25, 2009 at 6:19 AM, Timothy Perrett > wrote: >> >> Sorry Dave, but the brevity of your reply left me somewhat confused... >> "yes it makes sense to do that" or "yes, we'll be replacing everything with >> lift-json" ? > > Eventually, we'll be integrating all of lift-json into the existing Lift > JavaScript infrastructure. > >> >> Cheers, Tim >> On 25 Sep 2009, at 14:07, David Pollak wrote: >> >> On Fri, Sep 25, 2009 at 1:21 AM, Timothy Perrett >> wrote: >>> >>> Are there any plans to supersede the JsObj stuff with what is in lift- >>> json ? Seems like that would make a lot more sense, no? >> >> Yes. >> >>> >>> Cheers, Tim >>> >>> On 24 Sep 2009, at 22:13, Indrajit Raychaudhuri wrote: >>> >>> > >>> > >>> > On 24/09/09 2:34 PM, Timothy Perrett wrote: >>> >> >>> >> Nice stuff Joni! >>> > >>> > Indeed. That this module gets lots of love shows. >>> > Everything nice and tidy in a neat little package. >>> > >>> > Did I mention that it's test cases serve as docs too? >>> > >>> > /Indrajit >>> > >>> >> >>> >> Cheers, Tim >>> >> >>> >> On 24 Sep 2009, at 08:24, Joni Freeman wrote: >>> >> >>> >>> >>> >>> Hi, >>> >>> >>> >>> There is now improved XML support in lift master. See a short >>> >>> section >>> >>> in README: >>> >>> http://github.com/dpp/liftweb/tree/master/lift-json/ >>> >>> >>> >>> and some executable examples: >>> >>> >>> >>> http://github.com/dpp/liftweb/blob/master/lift-json/src/test/scala/net/liftweb/json/XmlExamples.scala >>> >>> >>> >>> Cheers Joni >>> >>> >>> >>> On Sep 2, 9:27 pm, harryh wrote: >>> Is there anything built into lift that will doXML-> JSON >>> conversion? For example: >>> >>> >>> >>> 1 >>> Harry >>> >>> >>> 2 >>> David >>> >>> >>> >>> to: >>> >>> { >>> "foos": { >>> "foo": [{ >>> "id": 1, >>> "name": "Harry" >>> }, >>> { >>> "id": 2, >>> "name": "David" >>> } >>> ] >>> >>> } >>> >>> Just checking to see if there was something Lift friendly to do >>> this >>> before writing my own (or picking a java library to use). >>> >>> -harryh >>> >>> >>> >>> >> >>> >> >>> >>> >>> > >>> > > >>> > >>> >>> >>> >> >> >> >> -- >> Lift, the simply functional web framework http://liftweb.net >> Beginning Scala http://www.apress.com/book/view/1430219890 >> Follow me: http://twitter.com/dpp >> Git some: http://github.com/dpp >> >> >> >> >> > > > > -- > Lift, the simply functional web framework http://liftweb.net > Beginning Scala http://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 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 -~--~~~~--~~--~--~---
[Lift] Re: XML -> JSON converter?
On Fri, Sep 25, 2009 at 6:19 AM, Timothy Perrett wrote: > Sorry Dave, but the brevity of your reply left me somewhat confused... "yes > it makes sense to do that" or "yes, we'll be replacing everything with > lift-json" ? > Eventually, we'll be integrating all of lift-json into the existing Lift JavaScript infrastructure. > > Cheers, Tim > > On 25 Sep 2009, at 14:07, David Pollak wrote: > > On Fri, Sep 25, 2009 at 1:21 AM, Timothy Perrett > wrote: > >> >> Are there any plans to supersede the JsObj stuff with what is in lift- >> json ? Seems like that would make a lot more sense, no? >> > > Yes. > > >> >> Cheers, Tim >> >> On 24 Sep 2009, at 22:13, Indrajit Raychaudhuri wrote: >> >> > >> > >> > On 24/09/09 2:34 PM, Timothy Perrett wrote: >> >> >> >> Nice stuff Joni! >> > >> > Indeed. That this module gets lots of love shows. >> > Everything nice and tidy in a neat little package. >> > >> > Did I mention that it's test cases serve as docs too? >> > >> > /Indrajit >> > >> >> >> >> Cheers, Tim >> >> >> >> On 24 Sep 2009, at 08:24, Joni Freeman wrote: >> >> >> >>> >> >>> Hi, >> >>> >> >>> There is now improved XML support in lift master. See a short >> >>> section >> >>> in README: >> >>> http://github.com/dpp/liftweb/tree/master/lift-json/ >> >>> >> >>> and some executable examples: >> >>> >> http://github.com/dpp/liftweb/blob/master/lift-json/src/test/scala/net/liftweb/json/XmlExamples.scala >> >>> >> >>> Cheers Joni >> >>> >> >>> On Sep 2, 9:27 pm, harryh wrote: >> Is there anything built into lift that will doXML-> JSON >> conversion? For example: >> >> >> >> 1 >> Harry >> >> >> 2 >> David >> >> >> >> to: >> >> { >> "foos": { >> "foo": [{ >> "id": 1, >> "name": "Harry" >> }, >> { >> "id": 2, >> "name": "David" >> } >> ] >> >> } >> >> Just checking to see if there was something Lift friendly to do >> this >> before writing my own (or picking a java library to use). >> >> -harryh >> >> >>> >> >> >> >> >> >>> >> > >> > > >> > >> >> >> >> > > > -- > Lift, the simply functional web framework http://liftweb.net > Beginning Scala http://www.apress.com/book/view/1430219890 > Follow me: http://twitter.com/dpp > Git some: http://github.com/dpp > > > > > > > -- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://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 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 -~--~~~~--~~--~--~---
[Lift] Re: XML -> JSON converter?
Sorry Dave, but the brevity of your reply left me somewhat confused... "yes it makes sense to do that" or "yes, we'll be replacing everything with lift-json" ? Cheers, Tim On 25 Sep 2009, at 14:07, David Pollak wrote: > On Fri, Sep 25, 2009 at 1:21 AM, Timothy Perrett > wrote: > > Are there any plans to supersede the JsObj stuff with what is in lift- > json ? Seems like that would make a lot more sense, no? > > Yes. > > > Cheers, Tim > > On 24 Sep 2009, at 22:13, Indrajit Raychaudhuri wrote: > > > > > > > On 24/09/09 2:34 PM, Timothy Perrett wrote: > >> > >> Nice stuff Joni! > > > > Indeed. That this module gets lots of love shows. > > Everything nice and tidy in a neat little package. > > > > Did I mention that it's test cases serve as docs too? > > > > /Indrajit > > > >> > >> Cheers, Tim > >> > >> On 24 Sep 2009, at 08:24, Joni Freeman wrote: > >> > >>> > >>> Hi, > >>> > >>> There is now improved XML support in lift master. See a short > >>> section > >>> in README: > >>> http://github.com/dpp/liftweb/tree/master/lift-json/ > >>> > >>> and some executable examples: > >>> http://github.com/dpp/liftweb/blob/master/lift-json/src/test/scala/net/liftweb/json/XmlExamples.scala > >>> > >>> Cheers Joni > >>> > >>> On Sep 2, 9:27 pm, harryh wrote: > Is there anything built into lift that will doXML-> JSON > conversion? For example: > > > > 1 > Harry > > > 2 > David > > > > to: > > { > "foos": { > "foo": [{ > "id": 1, > "name": "Harry" > }, > { > "id": 2, > "name": "David" > } > ] > > } > > Just checking to see if there was something Lift friendly to do > this > before writing my own (or picking a java library to use). > > -harryh > > >>> > >> > >> > >>> > > > > > > > > > > > > > > -- > Lift, the simply functional web framework http://liftweb.net > Beginning Scala http://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 -~--~~~~--~~--~--~---
[Lift] Re: XML -> JSON converter?
On Fri, Sep 25, 2009 at 1:21 AM, Timothy Perrett wrote: > > Are there any plans to supersede the JsObj stuff with what is in lift- > json ? Seems like that would make a lot more sense, no? > Yes. > > Cheers, Tim > > On 24 Sep 2009, at 22:13, Indrajit Raychaudhuri wrote: > > > > > > > On 24/09/09 2:34 PM, Timothy Perrett wrote: > >> > >> Nice stuff Joni! > > > > Indeed. That this module gets lots of love shows. > > Everything nice and tidy in a neat little package. > > > > Did I mention that it's test cases serve as docs too? > > > > /Indrajit > > > >> > >> Cheers, Tim > >> > >> On 24 Sep 2009, at 08:24, Joni Freeman wrote: > >> > >>> > >>> Hi, > >>> > >>> There is now improved XML support in lift master. See a short > >>> section > >>> in README: > >>> http://github.com/dpp/liftweb/tree/master/lift-json/ > >>> > >>> and some executable examples: > >>> > http://github.com/dpp/liftweb/blob/master/lift-json/src/test/scala/net/liftweb/json/XmlExamples.scala > >>> > >>> Cheers Joni > >>> > >>> On Sep 2, 9:27 pm, harryh wrote: > Is there anything built into lift that will doXML-> JSON > conversion? For example: > > > > 1 > Harry > > > 2 > David > > > > to: > > { > "foos": { > "foo": [{ > "id": 1, > "name": "Harry" > }, > { > "id": 2, > "name": "David" > } > ] > > } > > Just checking to see if there was something Lift friendly to do > this > before writing my own (or picking a java library to use). > > -harryh > > >>> > >> > >> > >>> > > > > > > > > > > > > -- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://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 -~--~~~~--~~--~--~---
[Lift] Re: XML -> JSON converter?
Are there any plans to supersede the JsObj stuff with what is in lift- json ? Seems like that would make a lot more sense, no? Cheers, Tim On 24 Sep 2009, at 22:13, Indrajit Raychaudhuri wrote: > > > On 24/09/09 2:34 PM, Timothy Perrett wrote: >> >> Nice stuff Joni! > > Indeed. That this module gets lots of love shows. > Everything nice and tidy in a neat little package. > > Did I mention that it's test cases serve as docs too? > > /Indrajit > >> >> Cheers, Tim >> >> On 24 Sep 2009, at 08:24, Joni Freeman wrote: >> >>> >>> Hi, >>> >>> There is now improved XML support in lift master. See a short >>> section >>> in README: >>> http://github.com/dpp/liftweb/tree/master/lift-json/ >>> >>> and some executable examples: >>> http://github.com/dpp/liftweb/blob/master/lift-json/src/test/scala/net/liftweb/json/XmlExamples.scala >>> >>> Cheers Joni >>> >>> On Sep 2, 9:27 pm, harryh wrote: Is there anything built into lift that will doXML-> JSON conversion? For example: 1 Harry 2 David to: { "foos": { "foo": [{ "id": 1, "name": "Harry" }, { "id": 2, "name": "David" } ] } Just checking to see if there was something Lift friendly to do this before writing my own (or picking a java library to use). -harryh >>> >> >> >>> > > > > --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Lift] Re: XML -> JSON converter?
On 24/09/09 2:34 PM, Timothy Perrett wrote: > > Nice stuff Joni! Indeed. That this module gets lots of love shows. Everything nice and tidy in a neat little package. Did I mention that it's test cases serve as docs too? /Indrajit > > Cheers, Tim > > On 24 Sep 2009, at 08:24, Joni Freeman wrote: > >> >> Hi, >> >> There is now improved XML support in lift master. See a short section >> in README: >> http://github.com/dpp/liftweb/tree/master/lift-json/ >> >> and some executable examples: >> http://github.com/dpp/liftweb/blob/master/lift-json/src/test/scala/net/liftweb/json/XmlExamples.scala >> >> Cheers Joni >> >> On Sep 2, 9:27 pm, harryh wrote: >>> Is there anything built into lift that will doXML-> JSON >>> conversion? For example: >>> >>> >>> >>> 1 >>> Harry >>> >>> >>> 2 >>> David >>> >>> >>> >>> to: >>> >>> { >>>"foos": { >>> "foo": [{ >>> "id": 1, >>> "name": "Harry" >>> }, >>> { >>> "id": 2, >>> "name": "David" >>> } >>> ] >>> >>> } >>> >>> Just checking to see if there was something Lift friendly to do this >>> before writing my own (or picking a java library to use). >>> >>> -harryh >>> >> > > > > --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Lift] Re: XML -> JSON converter?
This is really really great. Will totally help me out a lot. Thanks! -harryh On Sep 24, 3:24 am, Joni Freeman wrote: > Hi, > > There is now improved XML support in lift master. See a short section > in README:http://github.com/dpp/liftweb/tree/master/lift-json/ > > and some executable > examples:http://github.com/dpp/liftweb/blob/master/lift-json/src/test/scala/ne... > > Cheers Joni > > On Sep 2, 9:27 pm, harryh wrote: > > > Is there anything built into lift that will doXML-> JSON > > conversion? For example: > > > > > > > 1 > > Harry > > > > > > 2 > > David > > > > > > > to: > > > { > > "foos": { > > "foo": [{ > > "id": 1, > > "name": "Harry" > > }, > > { > > "id": 2, > > "name": "David" > > } > > ] > > > } > > > Just checking to see if there was something Lift friendly to do this > > before writing my own (or picking a java library to use). > > > -harryh --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Lift] Re: XML -> JSON converter?
On Thu, Sep 24, 2009 at 2:04 AM, Timothy Perrett wrote: > > Nice stuff Joni! > +1 > > Cheers, Tim > > On 24 Sep 2009, at 08:24, Joni Freeman wrote: > > > > > Hi, > > > > There is now improved XML support in lift master. See a short section > > in README: > > http://github.com/dpp/liftweb/tree/master/lift-json/ > > > > and some executable examples: > > > http://github.com/dpp/liftweb/blob/master/lift-json/src/test/scala/net/liftweb/json/XmlExamples.scala > > > > Cheers Joni > > > > On Sep 2, 9:27 pm, harryh wrote: > >> Is there anything built into lift that will doXML-> JSON > >> conversion? For example: > >> > >> > >> > >> 1 > >> Harry > >> > >> > >> 2 > >> David > >> > >> > >> > >> to: > >> > >> { > >> "foos": { > >> "foo": [{ > >> "id": 1, > >> "name": "Harry" > >> }, > >> { > >> "id": 2, > >> "name": "David" > >> } > >> ] > >> > >> } > >> > >> Just checking to see if there was something Lift friendly to do this > >> before writing my own (or picking a java library to use). > >> > >> -harryh > > > > > > > > > > -- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://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 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 -~--~~~~--~~--~--~---
[Lift] Re: XML -> JSON converter?
Nice stuff Joni! Cheers, Tim On 24 Sep 2009, at 08:24, Joni Freeman wrote: > > Hi, > > There is now improved XML support in lift master. See a short section > in README: > http://github.com/dpp/liftweb/tree/master/lift-json/ > > and some executable examples: > http://github.com/dpp/liftweb/blob/master/lift-json/src/test/scala/net/liftweb/json/XmlExamples.scala > > Cheers Joni > > On Sep 2, 9:27 pm, harryh wrote: >> Is there anything built into lift that will doXML-> JSON >> conversion? For example: >> >> >> >> 1 >> Harry >> >> >> 2 >> David >> >> >> >> to: >> >> { >> "foos": { >> "foo": [{ >> "id": 1, >> "name": "Harry" >> }, >> { >> "id": 2, >> "name": "David" >> } >> ] >> >> } >> >> Just checking to see if there was something Lift friendly to do this >> before writing my own (or picking a java library to use). >> >> -harryh > > > --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Lift] Re: XML -> JSON converter?
Hi, There is now improved XML support in lift master. See a short section in README: http://github.com/dpp/liftweb/tree/master/lift-json/ and some executable examples: http://github.com/dpp/liftweb/blob/master/lift-json/src/test/scala/net/liftweb/json/XmlExamples.scala Cheers Joni On Sep 2, 9:27 pm, harryh wrote: > Is there anything built into lift that will doXML-> JSON > conversion? For example: > > > > 1 > Harry > > > 2 > David > > > > to: > > { > "foos": { > "foo": [{ > "id": 1, > "name": "Harry" > }, > { > "id": 2, > "name": "David" > } > ] > > } > > Just checking to see if there was something Lift friendly to do this > before writing my own (or picking a java library to use). > > -harryh --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Lift] Re: XML -> JSON converter?
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 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 wrote: > > > Hi, > > > I just quickly spiked this and following works on my local branch: > > > scala> val xml = > > > > > > 1 > > Harry > > > > > > 2 > > David > > > > > > > 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: > > > > > > > 1 > > Harry > > > > > > > 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 -~--~~~~--~~--~--~---
[Lift] Re: XML -> JSON converter?
Nothing that I know of but maybe Joni could add it to the new json parse On Wednesday, September 2, 2009, harryh wrote: > > Is there anything built into lift that will do XML -> JSON > conversion? For example: > > > > 1 > Harry > > > 2 > David > > > > to: > > { > "foos": { > "foo": [{ > "id": 1, > "name": "Harry" > }, > { > "id": 2, > "name": "David" > } > ] > } > > Just checking to see if there was something Lift friendly to do this > before writing my own (or picking a java library to use). > > -harryh > > > -- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://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 -~--~~~~--~~--~--~---
[Lift] Re: XML -> JSON converter?
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 wrote: > > Hi, > > I just quickly spiked this and following works on my local branch: > > scala> val xml = > > > 1 > Harry > > > 2 > David > > > > 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: > > > > 1 > Harry > > > > 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 framework http://liftweb.net Beginning Scala http://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 -~--~~~~--~~--~--~---
[Lift] Re: XML -> JSON converter?
Hi, I just quickly spiked this and following works on my local branch: scala> val xml = 1 Harry 2 David 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: 1 Harry 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 --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---