Code Monkey home page Code Monkey logo

Comments (7)

getActivity avatar getActivity commented on May 25, 2024
Class Test {
    String name;
    String age = "28";
}

from gsonfactory.

getActivity avatar getActivity commented on May 25, 2024

小伙子,你可以这样写试试看

from gsonfactory.

tiamosu avatar tiamosu commented on May 25, 2024

小伙子,你可以这样写试试看

设置了默认值还是为null =-=

from gsonfactory.

getActivity avatar getActivity commented on May 25, 2024

小伙子,我试了一下,没有你说的这个问题,需要麻烦你下载一下源码,然后 debug 排查一下是哪行代码设置为空的。

from gsonfactory.

tiamosu avatar tiamosu commented on May 25, 2024

小伙子,我试了一下,没有你说的这个问题,需要麻烦你下载一下源码,然后 debug 排查一下是哪行代码设置为空的。

好的,谢谢,我这边看看

from gsonfactory.

tiamosu avatar tiamosu commented on May 25, 2024

小伙子,我试了一下,没有你说的这个问题,需要麻烦你下载一下源码,然后 debug 排查一下是哪行代码设置为空的。

您好,我这边测试了下,给参数设定默认值,java是正常的,kotlin还是为null,这个有什么需要注意的么

from gsonfactory.

tiamosu avatar tiamosu commented on May 25, 2024

小伙子,我试了一下,没有你说的这个问题,需要麻烦你下载一下源码,然后 debug 排查一下是哪行代码设置为空的。

您好,我这边测试了下,给参数设定默认值,java是正常的,kotlin还是为null,这个有什么需要注意的么

查到问题所在了,Gson解析需要一个空参构造,而kotlin如果构造中每个参数都有默认值的时候,会有一个空参,并且会正确的将默认值赋值。所以Gson可以正常解析。如果kotlin的构造有参数没有默认值,就会出此问题。-_-||
谢谢您的耐心解答

from gsonfactory.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.