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
4
votes
1 answer

How to serialize and deserialize Java 8 dateTime in lift JSON?

I have a case class which I want to serialize first. Then after that, I want to deserialize it for storing purpose in MongoDB but java 8 LocalDateTime was creating problem. I took help from this link: how to deserialize DateTime in Lift but with…
swaheed
  • 3,671
  • 10
  • 42
  • 103
4
votes
1 answer

Extracting json in Scala

I have the following data structure: val jsonStr = """ { "data1": { "field1": "data1", "field2": 1.0, "field3": true }, "data211": { "field1": "data211", "field2": 4343.0, …
Alan Coromano
  • 24,958
  • 53
  • 135
  • 205
4
votes
2 answers

Vector deserialization by using lift-json

How can i deserialize json array using lift-json to scala vector? For example: case class Foo(bar: Vector[Bar]) trait Bar { def value: Int } case class Bar1(value: Int) extends Bar case class Bar2(value: Int) extends Bar import…
3
votes
0 answers

Could not initialize class net.liftweb.json.DefaultFormats$

I am working in Scala programming language and I am trying to generate json from a case class. I am following instructions on this page. I have added dependency in pom.xml net.liftweb
user10360768
  • 225
  • 3
  • 14
3
votes
1 answer

scala weird symbol "_@" meaning

I am wondering what this scala symbol is: _@. (Search engines have trouble with weird characters so it's hard to find anything on google...) Here is the context: def doNodeParse(json: JValue): TreeNode = { json match { case…
anthonybell
  • 5,790
  • 7
  • 42
  • 60
3
votes
1 answer

Compilation error in code snippet by lift-json 3.0.1 to convert json arrays into comma-separated-strings

I'm trying to consume a json-formatted text and convert it into xml. I'm utilising lift-json for that matter. According to the lift-json documentation here (def toXml), I should be able to convert elements of json arrays into comma separated strings…
has981
  • 425
  • 4
  • 18
3
votes
1 answer

Is it possible to serialize non case classes in Scala?

Is it possible to serialize object of below class using Json4s or lift or any other library? class User(uId: Int) extends Serializable { var id: Int = uId var active: Boolean = false var numTweets: Int = 0 var followers: ArrayBuffer[Int] =…
alchemist
  • 41
  • 4
3
votes
0 answers

Ignore lazy vals while saving into couchdb using sohva

We're using sohva in project. It uses lift-json to serialize the model case classes to persist into CouchDB. We have lazy vals in these models which we don't want them get persisted. Is there a way to tell lift-json to ignore these attributes?
siliconsenthil
  • 1,380
  • 1
  • 14
  • 25
3
votes
1 answer

lift-json XPath \\ operator has different return type depending on num matches

I would expect json \\ "something" to always return the same type of object (or at least something that's always isomorphic) for the same query on data with the same schema, however, consider: val json1 = ("people" -> List( ("person" -> ("name" ->…
Erik Kaplun
  • 37,128
  • 15
  • 99
  • 111
3
votes
2 answers

JSON deserialization using reflection

Hi I am trying to extract a JSON using reflection import net.liftweb.json._ case class Bike(make: String, price: Int) { def this(price: Int) = this("Trek", price) } val cls = Class.forName("Bike") val manifest = Manifest.classType(cls) val…
igx
  • 4,101
  • 11
  • 43
  • 88
3
votes
1 answer

Scala type parameter seems to be getting "stuck"

I'm using lift-json to de-serialize JSON strings into Scala case classes. The JSON I'm parsing has a common structure: a data, success and error field, where data contains the interesting bits. I've created an APIResponse class to account for this…
2
votes
1 answer

json parsing using circe in scala

I'm trying to make use of circe for json parsing in scala. Can you please help me parse 'pocs' from the data in the case class as well? here is the code: import io.circe.Decoder import io.circe.generic.semiauto.deriveDecoder import…
Vish0111
  • 43
  • 6
2
votes
0 answers

Parsing json with dynamic types in scala with lift-json

I'm trying to write a JSON parse using lift-web and scala. I mapped my JSON to several case classes (for nested values/types), but I'm stuck with a MappingException error. This is the nested part of the JSON i'm trying to…
2
votes
1 answer

Unable to run simple lift web example

When I attempt to convert to JSON string from List I receive the compile-time error: 'JsonAST.RenderSettings.compact.type' does not take parameters src: import net.liftweb.json._ import net.liftweb.json.JsonDSL._ import…
blue-sky
  • 51,962
  • 152
  • 427
  • 752
2
votes
0 answers

Extracting the object from json returning "Executing command" in loop

I am trying to convert json string to case object, but unable to do so using liftjson. Below is the code for reference: import net.liftweb.json._ //implicit val formats = DefaultFormats // Brings in default date formats etc. case class Tmp(id: Int,…
1
2
3
8 9