今天需要把一个object对象转为jsonstring,刚开始尝试用fastjson
但是一直报
Error:(14, 18) ambiguous reference to overloaded definition,
both method toJSONString in object JSON of type (x$1: Any, x$2: com.alibaba.fastjson.serializer.SerializerFeature*)String
and method toJSONString in object JSON of type (x$1: Any)String
match argument types (Map[String,String]) and expected result type Any
println(JSON.toJSONString(maplevel1))
异常,方法重载异常,需要显示指明调用的哪个方法,
第二放弃fastjson
使用
json4s
测试代码
package project_session_spark.sparkapi import org.json4s._