Skip to main content

All Questions

Tagged with
1 vote
2 answers
2k views

How to make Jackson deserialize explicit null to Optional.EMPTY, but not to serialize empty Optional as null

Assuming I have a POJO like this: public static class Test { private Optional<String> something; } And a Jackson mapper like this: var OBJECT_MAPPER = JsonMapper.builder() .addModule(new ...
k.liakos's user avatar
  • 659
0 votes
1 answer
5k views

Jackson - Deserializing JSON into an Object having an Optional field

I have an Optional<Double> field which I am trying to deserialize from a JSON, but getting the following Exception: Cannot construct instance of `java.util.Optional` (although at least one ...
SDev's user avatar
  • 3
0 votes
0 answers
69 views

Getting API data + Optional Problems

I'm struggling to get an optional type to a Label.text. It keeps on giving me "nil" value and won't change the text. import UIKit class VerifyPNViewController: UIViewController { @...
077tech's user avatar
1 vote
1 answer
991 views

In Avro schema, how to wrap the array to an object and put it as a union instead of putting just array as union

I have the following data and I want to wrap the OPTIONAL array as an object and then put in as a union but since I am new to this, I am not sure how to do this. This is how I have done so far so ...
Atihska's user avatar
  • 5,032
1 vote
2 answers
220 views

JSON deserialization: input DateTime? to output Option<DateTime>

Context: one type has two representations: one in C# and one in F#. Value of the C# type gets serialized to json and then deserialized into a value of the F# type. Is there a straightforward way to ...
Piotr Justyna's user avatar
0 votes
1 answer
96 views

Managing My Hibernate POJO NullPointerException Using Optional

Hi Guys I'm a bit confused in regards to using the Optional with the Java POJO Hibernate. As a Java dev we always complaining about NullPointerException, you need to check for null before you access ...
Adam Obaidi's user avatar
0 votes
1 answer
2k views

SwiftUI Text View: When optional string is nil, expected default value is not working

Having trouble figuring out why code won’t display default value when variable is nil. Here’s the context below. Any pointers would be greatly appreciated. Thanks! EXAMPLE OF DATA FROM JSON API: NOTE: ...
Bei's user avatar
  • 49
0 votes
1 answer
977 views

Runtime error when deserialiasing in Jackson - InvalidDefinitionException

I'm currently working on a bug fix for the azure-sdk-for-java and when trying to deserialise some JSON into a class with an Optional, I am getting an InvlidDefinitionException. What am I doing wrong? ...
phil's user avatar
  • 313
0 votes
1 answer
574 views

A better way to extract the value of a field within an Option[JsValue] in scala?

I have a value in a JsObject which I want to assign to a specific key in Map, and I want to ask if there is a better way to extract that value without using a case matcher. I have access to a request ...
GabrielG's user avatar
0 votes
2 answers
465 views

Unwrap optional text from JSON

I have multiple strings returned from JSON and tried various options, but couldn't unwrap the optional content in it. Code snippet below let parsedData = try JSONSerialization.jsonObject(with: data!,...
Veepee's user avatar
  • 1
3 votes
1 answer
2k views

How to parse json file with std::optional< std::variant > type in C++?

How can I parse nested json in c++? I am looking for a json parser that is capable of parsing nested json. Especially this field in the example json below: optional<variant<bool, Secondary>&...
cpchung's user avatar
  • 804
3 votes
0 answers
207 views

Deserialize to Optional<List<MyPojo>> explodes with HttpMessageNotWritableException

I am using jackson-datatype-jdk8 library to deserialize from json to Optional fields in my POJO, configured via: objectMapper.registerModule(new Jdk8Module()); I am using Optional because I need to ...
Bohemian's user avatar
  • 421k
5 votes
3 answers
4k views

Distinguish null from missing properties in Jackson using Kotlin data classes

I want to use Jackson to deserialize and later serialize jsons using Kotlin's data classes. It's important that I maintain the distinction between an explicitly null property, and a property which was ...
A Frayed Knot's user avatar
5 votes
1 answer
3k views

Serializing Optional with Jackson: NON_ABSENT vs. configureAbsentsAsNulls and NON_NULL

When you want to serialize Optional with Jackson in Java, you must register the module Jdk8Module. This way, you either get the contained value or null. Now if you also set serialization feature ...
trondbt's user avatar
  • 51
5 votes
1 answer
3k views

Custom Deserialization of Generic Types in Jackson Kotlin/Java

With this data model... TestClass.kt data class TestClass (val bar: Optional<Double>?) My goal is to deserialize the following json values as such: {"foo": 3.5} --> foo = 3.5 {"foo": ...
A Frayed Knot's user avatar

15 30 50 per page
1
2 3 4 5