I am trying to define the Json string to convert that into a JSONObject. When i define the string as "String jsonObj = "{"abc":"efg"}";" in mule java class, it gives me "Syntax error on token, delete this token" error. Thanks!
Asked
Active
Viewed 58 times
2 Answers
0
You should escape double quotes with backslash:
String jsonObj = "\"{\"abc\":\"efg\"}\"";

Ivan Pronin
- 1,768
- 16
- 14
-
I have 100 object record and each has about 10 key value pair. do i need to manually do that? – Charu V Apr 06 '17 at 19:02
-
You better parse JSON directly from a file: http://stackoverflow.com/questions/2591098/how-to-parse-json-in-java – Ivan Pronin Apr 06 '17 at 19:04
-
Helpfull..Thanks – Charu V Apr 06 '17 at 19:19
0
You can also specify json in set payload and then use json-to-object

Suyog Sathe
- 114
- 1
- 1
- 5
-
I want to use the java class as a static and it's called by another java class – Charu V Apr 06 '17 at 19:04