All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.deepl.api.parsing.LanguageDeserializer Maven / Gradle / Ivy

The newest version!
// Copyright 2022 DeepL SE (https://www.deepl.com)
// Use of this source code is governed by an MIT
// license that can be found in the LICENSE file.
package com.deepl.api.parsing;

import com.deepl.api.Language;
import com.google.gson.*;
import java.lang.reflect.Type;

/**
 * Utility class for deserializing language codes returned by the DeepL API.
 *
 * 

This class is internal; you should not use this class directly. */ class LanguageDeserializer implements JsonDeserializer { public Language deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { JsonObject jsonObject = json.getAsJsonObject(); Boolean supportsFormality = Parser.getAsBooleanOrNull(jsonObject, "supports_formality"); return new Language( jsonObject.get("name").getAsString(), jsonObject.get("language").getAsString(), supportsFormality); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy