简体   繁体   中英

Using separate library within play framework

I tried using the lift-json library to convert XML to JSON in the following way: http://mkaz.com/solog/scala/how-to-convert-xml-to-json.html

in my controller.scala file. I then get the error:

The file /app/controllers.scala could not be compiled. Error raised is : missing arguments for method Xml in class ScalaController; follow this method with '_' if you want to treat it as a partially applied function

The error was highlighting:

val str = Printer.pretty(render(↓Xml.toJson(data))) 

I tried running my same code in another file and it worked, but it still does not work in the play framework.

Make sure you're not getting compiler warnings on symbols hiding other symbols - I'm not clear on where the error is exactly, but it's possible one of the symbols you import has overridden render . If that's the case you can rename on import like so:

import net.liftweb.json.{render => renderJson}
// ...
val str = Printer.pretty(renderJson(Xml.toJson(data)))

There's a typo in the line. See the down arrow just before Xml ? It shouldn't be there, but, since it is, it interprets Xml as a method.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM