I have a json in a string form and i want to parse it with JSONObject class in kotlin. However, i get an exception when i run a test to see if the function works. Below i have an example
When i run the test i get this result
Moreover, when i debug the function i see that it cannot parse the string to json.
Why is this happening??
I have a json in a string form and i want to parse it with JSONObject class in kotlin. However, i get an exception when i run a test to see if the function works. Below i have an example
When i run the test i get this result
Moreover, when i debug the function i see that it cannot parse the string to json.
Why is this happening??
To mock JSON, you can use Robolectric.
IMport it as shown in the guide and then just run test with it: @RunWith(RobolectricTestRunner.class)
"""
) in the definition ofinput
and avoid escaping the"
character. If nothing else, it will make the code more readable. – David Soroko Commented Jan 19 at 17:42