Question: So I have a Map in Scala like this:

```
val m = Map[String, String](
    "a" -> "theA",
    "b" -> "theB",
    "c" -> "theC",
    "d" -> "theD",
    "e" -> "theE"
)

```

and I want to serialize this structure into a JSON string using lift-json.

Do any of you know how to do this?

Answer: 
You can use this simple way if you are using play framework:

```
import play.api.libs.json._

Json.toJson(<your_map>)

```
Similar to Einar's solution, you can use JSONObject from [Parser Combinators](https://github.com/scala/scala-parser-combinators) to do this. Note that it does not recurse, you'll need to do this yourself. The library also includes JSONArray, for list like data structures. Something like the following will address Noel's concerns about nested structures. This example does not recurse to an arbitrary level, but will handle a value of **List[Map[String, Any]]**.

```
import scala.util.parsing.json.{JSONArray, JSONObject}

def toJson(m : Map[String, Any]): String = JSONObject(
  m.mapValues {
    case mp: Map[String, Any] => JSONObject(mp)
    case lm: List[Map[String, Any]] => JSONArray(lm.map(JSONObject(_)))
    case x => x
    }
  ).toString

```