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

Library Support #258

Closed
theapache64 opened this issue Nov 24, 2019 · 5 comments
Closed

Library Support #258

theapache64 opened this issue Nov 24, 2019 · 5 comments
Assignees
Labels
feature request L6 Difficulty level 6 (Maximum is 9)

Comments

@theapache64
Copy link
Collaborator

Is it possible to get a library version of the json-to-kotlin convertor where I'd pass the JSON string and get kotlin class string in return.

val kotlinClassString  = JsonToKotlinClass.toKotlinClass("moshi", myJsonString)
@wuseal
Copy link
Owner

wuseal commented Nov 25, 2019

@theapache64 Of course! It's easy to achieve that, If you have the interest, welcome to open a pull request. Or we will plan for it later
Tips:
enable Test config could make this library run well. 😄

 TestConfig.setToTestInitState()

@theapache64
Copy link
Collaborator Author

HI @wuseal

I was busy with some other work, that's why I closed the issue. Now am free and planning to develop the library, hence re-opening this issue.

I need some clarification on how the architecture works. When you'll be free for a quick chat?

@theapache64
Copy link
Collaborator Author

Below given proposed API structure for the library

    val output = JsonToKotlinBuilder(input, "GlossResponse")
            .setPropertyKeyword(PropertyKeyword.VAL)
            .setPropertyType(PropertyType.NON_NULLABLE)
            .setPropertyDefaultValueStrategy(PropertyDefaultValueStrategy.DONT_INIT_WITH_DEFAULT_VALUE)
            .setAnnotation(Annotation.MOSHI_CODEGEN)
            .setComment(true)
            .setOrderByAlphabetic(true)
            .setInnerClassModel(true)
            .setMapType(true)
            .setCreateAnnotationOnlyWhenNeeded(true)
            .setIndent(4)
            .setParentClassTemplate("MyParentClass")
            .setKeepAnnotationOnClass(true)
            .setKeepAnnotationOnClassAndroidX(true)
            .setKeepAnnotationAndPropertyInSameLine(true)
            .setParcelableSupport(true)
            .setPropertyPrefix("MyPrefix")
            .setPropertySuffix("MySuffix")
            .setClassSuffix("MyClassSuffix")
            .setForcePrimitiveTypeNonNullable(true)
            .setForceInitDefaultValueWithOriginJsonValue(true)
            .build()

@wuseal
Copy link
Owner

wuseal commented Nov 28, 2019

@theapache64 Wow! happy to hear your news. the proposed API seems good, a little update:

.setParentClassTemplate("MyParentClass")

should be like this:
.setParentClassTemplate("android.os.Parcelable")
including the package.

Others seem no problem.

@theapache64
Copy link
Collaborator Author

Sure brother

@wuseal wuseal added feature request L6 Difficulty level 6 (Maximum is 9) labels Nov 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request L6 Difficulty level 6 (Maximum is 9)
Projects
None yet
Development

No branches or pull requests

2 participants