Ollama4j
A Java library (wrapper/binding) for Ollama server.
Loading...
Searching...
No Matches
BooleanToJsonFormatFlagSerializer.java
Go to the documentation of this file.
1/*
2 * Ollama4j - Java library for interacting with Ollama server.
3 * Copyright (c) 2025 Amith Koujalgi and contributors.
4 *
5 * Licensed under the MIT License (the "License");
6 * you may not use this file except in compliance with the License.
7 *
8*/
9package io.github.ollama4j.utils;
10
11import com.fasterxml.jackson.core.JsonGenerator;
12import com.fasterxml.jackson.databind.JsonSerializer;
13import com.fasterxml.jackson.databind.SerializerProvider;
14import java.io.IOException;
15
16public class BooleanToJsonFormatFlagSerializer extends JsonSerializer<Boolean> {
17
18 @Override
19 public void serialize(Boolean value, JsonGenerator gen, SerializerProvider serializers)
20 throws IOException {
21 gen.writeString("json");
22 }
23
24 @Override
25 public boolean isEmpty(SerializerProvider provider, Boolean value) {
26 return !value;
27 }
28}
void serialize(Boolean value, JsonGenerator gen, SerializerProvider serializers)