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.

Empty fields in jsonb[] giving exception for a select query

See original GitHub issue

For an array of JsValue when one of the values for a field is empty string, I’m getting Json.parse(_) exception for the select query. Is this related to utils.SimpleArrayUtils.fromString ?

    implicit val playJsonArrayTypeMapper =
      new AdvancedArrayJdbcType[JsValue](pgjson,
        (s) => utils.SimpleArrayUtils.fromString[JsValue](Json.parse(_))(s).orNull,
        (v) => utils.SimpleArrayUtils.mkString[JsValue](_.toString())(v)
      ).to(_.toList)

Example Jsonb[]:

[{
     "id": "1",
     "type": ""
},
{
      "id": "2",
     "type": "GET"
}]

Unexpected character ('}' (code 125)): expected a value

Example:

[{
     "id": "1",
     "type": "",
     "url": "google.com"
}]

Unexpected character (',' (code 40)): expected a value

I think this was a similar issue for string #294.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
tmingleicommented, Apr 4, 2018

@dineyw23 fixed, pls help check. Thanks! 👍

0reactions
tmingleicommented, Apr 6, 2018

@dineyw23 don’t mind those warnings, it’s OK.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to query a json column for empty objects? - Stack Overflow
In Postgres 9.4 or later, cast to jsonb instead. (Or use jsonb to begin with.) However, for this particular case (empty object) it...
Read more >
Handling JSON null and empty arrays and objects - IBM
Handling null and empty arrays and objects used in JSON data is described. ... If the property is not defined as nillable, it...
Read more >
Documentation: 15: 8.14. JSON Types - PostgreSQL
JSON data types are for storing JSON (JavaScript Object Notation) data, as specified in RFC 7159. Such data can also be stored as...
Read more >
Solve common issues with JSON in SQL Server
I want to create a JSON text result from a simple SQL query on a single table. FOR JSON PATH and FOR JSON...
Read more >
Setting Empty-String JSONB Values to Null When Sorting with ...
argument that we've stated in our SELECT statement (via our Ransack query). Here's what the resulting query looks like: SELECT DISTINCT "members ...
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