java - Scala parse a JSON into a Map alternatives -
i'm looking alternatives scala json.parsefull(jsonstring). i'm using scala json convert jsonstring map[string,any] takes long convert map, , build java object it. jsonstring long json response.
do know fastest ways convert jsonstring map[string, any] can patternmatching after that?
here goes code json.parsefull():
override def parse(in: string): responseobject = { val json: option[any] = json.parsefull(in) json match { case some(value) => val map: map[string, any] = value.asinstanceof[map[string, any]] //json root val data: map[string, any] = map.get("data").get.asinstanceof[map[string, any]] //populate psmsearchresponse val response: responseobject = new responseobject //mapping base properties response.sethash(data.get("hash").get.asinstanceof[string]) //call "transformtopsmitem" function map each searchitem val items: list[responseobjectitem] = data.get("items").get.asinstanceof[list[any]] map { itemparser.transformtoresponseobjectitemitem } response.setitems(new arraylist(items.asjavacollection)) //return complete psmsearchresponse response case (none) => null }
i have tried lift-json i'm using scala 2.10 cant make work.
val record = json.jsonparser.parse(json) val json : option[any] = record.values.asinstanceof[map[string, any]]
i'm getting error incompatibility of scala version (2.10) , json-lift version.
i know if worth trying libraries , dealing problems little time improvement... if knows fastes way please tell me.
thanks !
Comments
Post a Comment