Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Super Contributor
Posts: 257
Registered: ‎05-05-2011
My Device: 9700
Accepted Solution

Properly remove double quotes

Hi everybody,

 I face a bit annoying problem with double quotes: I  have JSON string with double quotes inside which causes incorrect parsing. So I want to completely remove them. I used

 

result_text = result_text.replace('"', '\"');

 but no changes. I searched a bit and found that people use replace(String, String) while I can see only one constructor with chars. To be general - how would you remove double quotes from a string?

Developer
Posts: 77
Registered: ‎04-01-2011
My Device: Bold 9700

Re: Properly remove double quotes

Your method replaces a " with a ", so there would be no changes. 

 

What you want depends on your JDK. Read this article .

Super Contributor
Posts: 257
Registered: ‎05-05-2011
My Device: 9700

Re: Properly remove double quotes

yeah, coding at night is evil:smileyhappy: stupid code **bleep**)and  great link

Super Contributor
Posts: 257
Registered: ‎05-05-2011
My Device: 9700

Re: Properly remove double quotes

Ok, I tested methods in this link, but still have problems with parsing json... Do you know how to change jdk to be able to use .replaceAll(String, String) method? Or what can be the problem with these string methods?

Contributor
Posts: 17
Registered: ‎01-13-2011
My Device: Blackberry 9900

Re: Properly remove double quotes

Take a look at net.rim.device.api.util.Stringutilities, this has the method removeChars.  

 

http://www.blackberry.com/developers/docs/4.6.0api/net/rim/device/api/util/StringUtilities.html

 

Jonathan

Super Contributor
Posts: 257
Registered: ‎05-05-2011
My Device: 9700

Re: Properly remove double quotes

thank you too:smileyhappy: I looked through this class, can be useful in some cases.

I also tried http://supportforums.blackberry.com/t5/Java-Development/String-Manipulation-split-replace-replaceAll..., nice solution

 and to cut long story short - my problem with json happened to be far from quotes. I just have not worked with json parser before and attempted to get null value. Now I parse it properly:smileyhappy: