Empty fields in jsonb[] giving exception for a select query
See original GitHub issueFor 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:
- Created 5 years ago
- Comments:5 (3 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@dineyw23 fixed, pls help check. Thanks! 👍
@dineyw23 don’t mind those warnings, it’s OK.