I have a json file from which I read an array of objects.
Now I have situation where, if some object contains \n, then I have to do some extra operations. To check whether the objects contain \n, or not, I do the following...
String normalString = 'somethin \n and something';
String jsonString = jsonFileData['some_field'];
print(normalString.contains('\n')); //true
print(jsonString.contains('\n')); // false
If I do string.contains() with simple string it returns true, but if I check check the json file as a string false is returned.
Why is this so?
The most probable answer to your question is that jsonFileData['some_field'] is not a string. As you are putting it in a string, the toString method is called on that object and returns something that is not what you intend. Thus, when you search for '\n', it is not found.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With