Skip to content

caution when using custom scalars ... must be JSON encodable #4

Description

@hlship

Tracking down a problem with the latest upgrade. Because of a resolve failure, the arguments to a field are included in an error map; one value is a java.time.LocalDateTime. Cheshire throws an exception when streaming this as JSON, and the final result is a response with a body that is the empty string.

The right solution is to use cheshire.generator/add-encoder:

(add-encoder LocalDateTime
             (fn [v ^JsonGenerator json-generator]
               (.writeString json-generator (format-local-date-time v)))) 

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions