如何在Scala中将Map转换为Json

时间:2016-08-23 12:20:49

标签: json scala

我的地图如下:

{'message': 'Conditions can be of length 1 or 2 only'}

我想要JSON数组,如下所示:

    String keyQuery = " hashKey = :hashKey and rangeKey between :start and :end "
    queryRequest.setKeyConditionExpression(keyQuery)// define key query
    String filterExpression = " yourParam = :yourParam "
    queryRequest.setFilterExpression(filterExpression)// define filter expression
    queryRequest.setExpressionAttributeValues(expressionAttributeValues)
    queryRequest.setSelect('ALL_ATTRIBUTES')
    QueryResult queryResult = client.query(queryRequest)

请提供建议。

提前谢谢。

1 个答案:

答案 0 :(得分:1)

vm.view = { dataTable: vm.myData, order: { classification: 'lastname', orderby: '+' } };

怎么样?
net.liftweb.json.DefaultFormats

并输出:

import net.liftweb.json.JsonAST
import net.liftweb.json.JsonDSL._
import net.liftweb.json.Printer.{compact,pretty}

object LiftJsonWithCollections extends App {

    val json = List(1, 2, 3)
    println(compact(JsonAST.render(json)))

    val map = Map("1" -> "one", "2" -> "two")
    println(compact(JsonAST.render(map)))
}

只需将[1,2,3] {"1":"one","2":"two"} 的内容替换为拥有。