question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Spray-json None values are always converted to null. How to change this?

See original GitHub issue

Spray converts None values to null only when NullOptions trait is added but by default it doesn’t add those fields to JSON. When using kebs implicitly[RootJsonFormat[xxx]], it converts None values to null. Example of such case: https://scastie.scala-lang.org/myDisconnect/tgnMaqh4QcCdQWDBWQZT5A/7 see f4 field (this is also visible in Kebs tests) Is it possible to change this behaviour in Kebs and ignore None values?

Note: This seems to be happening when a case class has more than 22 parameters

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
pk044commented, Sep 19, 2020

@myDisconnect FYI: the new release is already available on Maven Central

1reaction
pk044commented, Sep 15, 2020

@myDisconnect We will try to get it released this week.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Spray-Json: serialize None as null - scala - Stack Overflow
1 Answer 1 ; case class Response(result: Int, error: Option[String]) ; implicit val responseFormat = jsonFormat2( ; import ResponseProtocol._ ; 42 ...
Read more >
spray/spray-json: A lightweight, clean and simple ... - GitHub
A lightweight, clean and simple JSON implementation in Scala - GitHub ... spray-json will always read missing optional members as well as null...
Read more >
how to handle null value in spray-json? - Google Groups
It comes done with Null value handling. Here is an example of the Wine json format: { "id": 13, "name": "ARGIANO NON CONFUNDITUR",...
Read more >
Implicit resolution in Scala: an example with spray-json
From the “ambiguous implicit values” error message, we can understand that the compiler has two ways of implicitly generating a JsonWriter[List] ...
Read more >
spray.json.JsObject Scala Example - ProgramCreek.com
This page shows Scala examples of spray.json.JsObject. ... JsonError \/ (String, JsValue) = field.value match { case None ... Is always false for...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found