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

--~--~---------~--~----~------------~-------~--~----~
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