You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My app does not use Compose Multiplatform. It uses shared logic and native UI.
I added an example.json (mocked JSON response). to the root/shared/src/commonMain/moko-resources/files/ folder.
inside root/shared/src/commonMain, I created a mock repository class that should read the contents of the file to a String variable and then I can use kotlinx-serialization to serialize it.
This is the relevant function in my mock repository class:
funreadJsonFromResource() {
val fileResource =SharedRes.files.example_json // FileResourceval jsonAsString:String=// How to read the contents of the resource in here?// Todo: Serialize string.
}
How do I achieve this? Is there example code? FileResource does not seem to have any methods for getting the string from its contents.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
My app does not use Compose Multiplatform. It uses shared logic and native UI.
I added an
example.json
(mocked JSON response). to theroot/shared/src/commonMain/moko-resources/files/
folder.inside
root/shared/src/commonMain
, I created a mock repository class that should read the contents of the file to aString
variable and then I can usekotlinx-serialization
to serialize it.This is the relevant function in my mock repository class:
How do I achieve this? Is there example code?
FileResource
does not seem to have any methods for getting the string from its contents.Beta Was this translation helpful? Give feedback.
All reactions