question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Document using Gson mapper in Kotlin

See original GitHub issue

👋 hi! I’ve been taking a look at Javalin today, and have been considering converting a tiny ktor project to it (the tl;dr there being that most of the addons to ktor that make it a more complete framework are still labeled “experimental,” and I don’t really need the async capabilities it has).

One stumbling block along the way was that I wanted to use Gson (since my existing resources were already relying on it), but trying to set:

val gson = GsonBuilder().create()
JavalinJson.fromJsonMapper = gson::fromJson

lead to a rather verbose type error.

After googling a bit, I eventually found the example you added to this repo, which appears to work. It would be nice if a link to this could be added to the documentation under “configuring the JSON mapper”, since it took me a while to find that.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
thomasboytcommented, Feb 20, 2020

Whoops, this slipped my mind. Should be able to do this in the next day or two!

0reactions
tipsycommented, Feb 20, 2020

Should I take over this @thomasboyt ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Kotlin - Convert object to/from JSON string using Gson
Gson is a Java/Kotlin library for converting Java/Kotlin Objects into JSON representation, also a JSON string to an equivalent Java/Kotlin ...
Read more >
Converting Kotlin Data Class from JSON using GSON
1. Overview. In this short tutorial, we'll discuss how to convert a data class in Kotlin to JSON string and vice versa using...
Read more >
Parsing between JSON and Kotlin Object with Google Gson ...
In this tutorial I will discuss about how to parse a class object into json string and convert it back from json string...
Read more >
Kotlin Data Class from Json using GSON - java - Stack Overflow
@AntonGolovin I am not able to pass my data class in from Json method.Do I need to declare my data class inside java...
Read more >
Convert Object to/from JSON with Gson - Kotlination
This tutorial shows you how to use Gson to convert Kotlin object to/from JSON.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found