Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate from a base class(使用一个基类来生成解析类) #59

Open
everyline opened this issue Jun 11, 2018 · 10 comments
Open

Generate from a base class(使用一个基类来生成解析类) #59

everyline opened this issue Jun 11, 2018 · 10 comments
Labels
enhancement help wanted L9 Difficulty level 9 (Maximum is 9)
Milestone

Comments

@everyline
Copy link

No description provided.

@wuseal
Copy link
Owner

wuseal commented Jun 11, 2018

@everyline 嗨,什么意思,可以的话请麻烦把问题说明具体些 ,如果可以举例说明那更好

@everyline
Copy link
Author

default
default
就是一个基类 然后新建的类都完全可以继承他的所有参数 gsonfomat这个插件 解析的时候可以做到

@wuseal
Copy link
Owner

wuseal commented Jun 28, 2018

@everyline 非常感谢你的建议,这个我们的插件暂时不支持这样的功能,不过以后可能会加入这项功能。

@kezhenxu94 kezhenxu94 changed the title 继承的时候 不能 直接 解析 Generate from a base class(使用一个基类来生成解析类) Oct 28, 2018
@kezhenxu94
Copy link
Collaborator

kezhenxu94 commented Oct 28, 2018

@everyline 明确一下需求,你是想在根据 json 生成类的时候,指定一个基类,所有生成的类都继承这个基类,然后复用所有在基类中已经声明过的字段,对吧?

Translated: To make it clearly, you want to specify a base class, from which all the generated classes should extend, and reuse all the properties declared in the base class, right?

@everyline
Copy link
Author

@everyline 明确一下需求,你是想在根据 json 生成类的时候,指定一个基类,所有生成的类都继承这个基类,然后复用所有在基类中已经声明过的字段,对吧?

Translated: To make it clearly, you want to specify a base class, from which all the generated classes should extend, and reuse all the properties declared in the base class, right?

yes , That's true.

@everyline
Copy link
Author

@everyline 明确一下需求,你是想在根据 json 生成类的时候,指定一个基类,所有生成的类都继承这个基类,然后复用所有在基类中已经声明过的字段,对吧?

Translated: To make it clearly, you want to specify a base class, from which all the generated classes should extend, and reuse all the properties declared in the base class, right?

Is this possible? This is common in normal projects

@kezhenxu94 kezhenxu94 added this to To do in JsonToKotlinClass Mar 24, 2019
@wuseal wuseal added this to the someday milestone May 9, 2019
@wuseal wuseal pinned this issue Jun 25, 2019
@wuseal wuseal added the L9 Difficulty level 9 (Maximum is 9) label Jun 26, 2019
@wuseal
Copy link
Owner

wuseal commented Mar 25, 2020

As a workaround, we could customize this plugin with the Extension module to write an Extension to fill out parent class fields and add a parent class template.

But the problem is, for each parent class, we'll need to write one Extension implementation.

Please see here to know about Extension : https://github.com/wuseal/JsonToKotlinClass/blob/master/doc_for_extensions.md

@iOrchid
Copy link

iOrchid commented Apr 23, 2020

翻看了issues,似乎没看到类似的,或许是我没找到。给大佬提个建议,生成的data class,能否按照json的层级格式,同样的嵌套data class,这样会便于一些场景中,避免同名class的创建冲突。

@xurui1995
Copy link
Collaborator

xurui1995 commented Apr 23, 2020

翻看了issues,似乎没看到类似的,或许是我没找到。给大佬提个建议,生成的data class,能否按照json的层级格式,同样的嵌套data class,这样会便于一些场景中,避免同名class的创建冲突。

@zhiwei1990 你好,不知道这个是否符合你的需求?
image

@iOrchid
Copy link

iOrchid commented Apr 23, 2020

翻看了issues,似乎没看到类似的,或许是我没找到。给大佬提个建议,生成的data class,能否按照json的层级格式,同样的嵌套data class,这样会便于一些场景中,避免同名class的创建冲突。

@zhiwei1990 你好,不知道这个是否符合你的需求?
image

多谢,😅尴尬了,是这么个用法

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement help wanted L9 Difficulty level 9 (Maximum is 9)
Projects
Development

No branches or pull requests

5 participants