Questions tagged [lift-json]

the lift-json parsing and formatting utilities for JSON

A JSON abstract syntax tree (AST) providing the following features:

  • Fast JSON parser
  • LINQ style queries
  • Case classes can be used to extract values from parsed JSON
  • Diff & merge
  • DSL to produce valid JSON
  • XPath like expressions and HOFs to manipulate JSON
  • Pretty and compact printing
  • XML conversions
  • Serialization
  • Low level pull parser API

Github: https://github.com/lift/lift/tree/master/framework/lift-base/lift-json/

130 questions
0
votes
2 answers

Json string to Map in Scala --> Liftweb

This is my input structure. All the fields here are optional because it can have zero or more elements in this json string. I am fine to use liftweb or regular scala. { "fname" : String, "lname" : String, "age" : String, "gender" : …
Revathi P
  • 77
  • 13
0
votes
0 answers

Modify json string from response in scala

I am trying to parse json using lift json in scala which I received from post call as a response string and update fields in json and then make put call with the modified json. Response string {"id":x,"status":"xxx","Ip":xxxx} I want to modify…
Dot Net Dev 19
  • 345
  • 2
  • 12
0
votes
0 answers

Scala/Lift: How to parse json to a case class?

We query an api with a list of items. Their response comes back giving status for each item like this: {"Results":[ {"item1":{"status": "whatever1", "cid":"blah1"}}, {"item2":{"status": "whatever2", "cid":"blah2"}} ]} item1 and item2 are ids…
An Illusion
  • 769
  • 1
  • 10
  • 24
0
votes
0 answers

Dynamic Json Keys in Scala

I'm new to scala (from python) and I'm trying to create a Json object that has dynamic keys. I would like to use some starting number as the top-level key and then combinations involving that number as second-level keys. From reading the play-json…
0
votes
1 answer

With lift-json or json4s how can I map fields of Option[String] to None in the case of empty string?

This test should explain what I'm trying to do, thanks: import com.typesafe.scalalogging.StrictLogging import net.liftweb.json._ import org.specs2.mutable.Specification object Dummy { case class Person(first: String, last: String, job:…
jpswain
  • 14,642
  • 8
  • 58
  • 63
0
votes
1 answer

Get case class and JSON object from a hierarchical JSON map with lift-json

I get maps such as: Map(reference -> Map(scriptRenderings -> List(Map(text -> महा-सुभाषित-सङ्ग्रहे 9979, scheme -> null, startLetter -> म)), jsonClass -> QuoteText, metre -> None, key -> महा-सुभाषित-सङ्ग्रहे9979, language -> Map(code -> UNK))) from…
vishvAs vAsuki
  • 2,421
  • 2
  • 18
  • 19
0
votes
2 answers

Scala: how to selectively write fields of an object to json string?

I have a query object: case class SearchQuery(keyword: String, count: Int, sort: String) I serialize this object to send it to a restful api to get search response. Is it possible to not write some of the properties when serializing based on some…
An Illusion
  • 769
  • 1
  • 10
  • 24
0
votes
1 answer

Scala Lift JSON error that is not fixed with normal solution

I have the following Scala project on GitHub. In that repo I have a class, Configurator, whose job it is to read a JSON file's contents into a string, and then use the Lift JSON library to deserialize the string into an instance of an…
smeeb
  • 27,777
  • 57
  • 250
  • 447
0
votes
1 answer

scala json serialization missing fields (json4s)

I am using json4s to serialize some scala map objects. import org.apache.spark.util.StatCounter import org.json4s.DefaultFormats val m: scala.collection.Map[String, Map[String, StatCounter]] = Map("key" -> Map("secondKey" ->…
Georg Heiler
  • 16,916
  • 36
  • 162
  • 292
0
votes
1 answer

error while loading DefaultFormats, Scala signature DefaultFormats has wrong version

I am trying to parse json using lift-json. I am following this link: http://alvinalexander.com/scala/scala-json-array-parser-parsing-example-lift-json. I am encountering the following error: error while loading DefaultFormats, Scala signature…
Ravi Ranjan
  • 353
  • 1
  • 6
  • 22
0
votes
0 answers

using lift-json for parsing in scala in SBT

I am trying to use lift-json to parse json. Have been to this link https://github.com/lift/lift/tree/master/framework/lift-base/lift-json/ and as suggested have added val lift_json = "net.liftweb" %% "lift-json" % "2.9" to "built.sbt". "import…
Ravi Ranjan
  • 353
  • 1
  • 6
  • 22
0
votes
1 answer

Converting to net.liftweb.json.JsonAST.JObject Lift in Scala

I am trying to construct a JSON object from a list where key is "products" and value is List[Product] where Product is a case class.But I am getting error that says "type mismatch; found : (String, List[com.mycompnay.ws.client.Product]) required:…
Sakalya
  • 568
  • 5
  • 15
0
votes
1 answer

How to add type hints for class with custom serializer in lift-json?

We have an existing class A, that previously was the only type that could appear in a certain position in the JSON output of our REST API endpoint. However, I'm now making it extend a common base class B so that a range of different types, all…
Robin Green
  • 32,079
  • 16
  • 104
  • 187
0
votes
1 answer

how to use lift json2.6.2 remove field by name?

use removeField can filter JFiled by name at 3.0M8 version.How about 2.6.2? It not have that method and remove method not catch name.
LoranceChen
  • 2,453
  • 2
  • 22
  • 48
0
votes
1 answer

Scala Match may not be exhaustive, JSON library-net.liftweb.json._

I am trying to hit an API and retreive JSON. I am trying to iterate on records and trying to fetch results. The problem is that below are the warnings which are being populated as errors. I don't want to make them as warnings, but to find out what…
safian syed
  • 147
  • 1
  • 6
1 2 3
8 9