• r

    rocketraman

    1 year ago
    Let me ask the question again in a different way. Obviously its possible to retrieve a serializer if one knows the type e.g.:
    val stringToColorMapSerializer: KSerializer<Map<String, Color>> = serializer()
    However, is it possible to retrieve a serializer generically? Since
    class
    definitions can't have reified
    T
    , the normal workaround is to pass in a
    Class<T>
    . If I know that
    T
    is an
    @Serializable
    can I get the
    KSerializer<T>
    from
    Class<T>
    ?
    r
    e
    +1
    13 replies
    Copy to Clipboard
  • Chris Fillmore

    Chris Fillmore

    1 year ago
    The only thing I want to serialize in the above is the
    headers
    , which I can get from
    toMap()
    Chris Fillmore
    rnett
    3 replies
    Copy to Clipboard
  • Thomas

    Thomas

    1 year ago
    I noticed that kotlinx.serialization has support for Linux arm targets. It would be great if you could share how you set up testing for those targets. I would really like to see Linux arm support for kotlinx.coroutines but it is unsupported due to testing. Could someone from kotlinx.serialization please share their experience here? https://github.com/Kotlin/kotlinx.coroutines/issues/855
    Thomas
    Vsevolod Tolstopyatov [JB]
    2 replies
    Copy to Clipboard
  • b

    Byron Katz

    1 year ago
    I want to catch on that so I can switch it to our own application exception, but in the current circumstances all I can do is catch on a general exception.
    b
    m
    +1
    4 replies
    Copy to Clipboard
  • pajatopmr

    pajatopmr

    1 year ago
    I am trying to model a TypeScript document using Kotlin. No small challenge. Any suggestions on how to model something like this snippet:
    someProvider?: boolean | string | SomeOptions;
    My current solution is to create a sealed class
    SomeProvider
    with subclasses:
    BooleanProvider
    ,
    StringProvider
    , and
    OptionsProvider
    so that I have the Kotlin snippet,
    someProvider: SomeProvider?
    which works but feels sub-optimal. Alternative suggestions much appreciated.
    pajatopmr
    andylamax
    2 replies
    Copy to Clipboard
  • pajatopmr

    pajatopmr

    1 year ago
    A more general statement of my previous question for dealing with the Language Server Protocol (LSP) might be: when encountering a single JSON element (same name == "fieldName") that can be a primitive (
    "fieldName":234
    ), a structure (
    "fieldName":{...}
    ) or an array (
    "fieldName":["string1","string2","string3"]
    ), what is the most logical/appropriate KSX feature for handling the serialization of that JSON element. JsonContentPolymorphicSerializer has proven to be very helpful for "regular" TypeScript <-> Kotlin interface mappings, i.e. interface constructs that appear nearly the same in both languages. It is when TypeScript can have one of primitive, object and/or array JSON elements that it gets much harder, at least as I understand KSX so far. My current thinking is that the most likely feature to use is the experimental one ("Under the hood") in the Json Transformations in the fifth chapter of the Kotlin Serialization Guide. If there is an easier approach, I'd love to hear about it.
    pajatopmr
    Nikky
    2 replies
    Copy to Clipboard
  • andylamax

    andylamax

    1 year ago
    All over a sudden,
    Person.serializer().list
    can't be resovled. How do I get a list serializer in
    kotlinx-serilialization-1.0.1
    ?
    andylamax
    rnett
    2 replies
    Copy to Clipboard
  • a

    Azur Haljeta

    1 year ago
    Is there any quick API to put a simple value into a
    JsonObject
    without unboxing the whole object?
    a
    russhwolf
    +1
    7 replies
    Copy to Clipboard
  • pajatopmr

    pajatopmr

    1 year ago
    My next serialization challenge is to conjure up a serializer for the abstract class Number. My first guess would be to use @Contextual. Good guess? But since I may have to tweak the actual Json, JsonTransformingSerializer might be better.
    pajatopmr
    1 replies
    Copy to Clipboard
  • a

    adk

    1 year ago
    Is there a way to have a subclass serialized with the custom serializer of its superclass, without having to declare
    @Serializable(with= ... )
    on every subclass?
    a
    Javier
    14 replies
    Copy to Clipboard