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.

Invalid names inside serialization

See original GitHub issue

Hello!

When using “kotlin.js.compiler=ir” breaks the field names. Incorrect field names then do not work in the tabulator

Without kotlin.js.compiler=ir

image

With kotlin.js.compiler=ir image


// model
@Serializable
data class Test(
    var id: Int? = null,
    var name: String? = null,
    var text: String? = null,
)

//service
@KVService
interface IPingService {
    suspend fun ping(test: Test): Test
}

// backend
actual class PingService : IPingService {
    override suspend fun ping(test: Test): Test {
        println(test)
        return test
    }
}

//frontend
object Model {
    private val pingService = PingService()
    suspend fun ping(test: Test): Test {
        return pingService.ping(test)
    }
}
class App : Application() {
    override fun start(state: Map<String, Any>) {
        val root = root("kvapp") {
        }
        AppScope.launch {
            val pingResult = Model.ping(Test(name= "Hello world from client!"))
            console.log("pingResult = ",pingResult)
        }
    }
}

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
rjaroscommented, Oct 29, 2021

Hi. When using IR compiler with Tabulator you can do two things.

  1. You can add @JsExport annotation to your model data class and use var’s instead of val. This works only with simple data classes.
  2. Or, when your model class is serializable, you can pass serializer = Test.serializer() parameter to your tabulator construtor/builder. It should work even with complex classes.
0reactions
GrishinSergeyAlcommented, Oct 29, 2021

Or, when your model class is serializable, you can pass serializer = Test.serializer() parameter to your tabulator construtor/builder. It should work even with complex classes.

Thanks, it works! Thanks again for the KVision!

Read more comments on GitHub >

github_iconTop Results From Across the Web

XML Serialization of an Object Containing invalid chars
Well, I've gone with this solution. · You're in good shape, unless the invalid characters were actually important. · 1 · 2 ·...
Read more >
Enforce valid XML tags in NVP · Issue #168 - GitHub
In some situations it is possible to compile code that will generate XML tags that are invalid. For example: template<class Ar> void serialize( ......
Read more >
Object Serialization Enhancements in Previous Releases
Bug fix: Invalid serialPersistentFields field name causes ... Serialization will now throw InvalidClassExceptions in such cases (since it is never necessary ...
Read more >
How to write custom converters for JSON serialization - .NET
Json , see How to serialize and deserialize JSON in .NET. ... InvariantCulture); public override void Write( Utf8JsonWriter writer, ...
Read more >
Serialize JSON with invalid C# names - Unity Answers
Serialize JSON with invalid C# names. Hi all I have an existing Rest API ... Sadly C# does not support the - as...
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