Hi all,
I would like to replace "true" by true and "false" by false in a JSON formatted string in Cobol.
For eg : a:"true" need to be replaced as a:true and b:"false" need to be replaced by b:false.
The replacement should happen for all occurences of "true" and "false" in the string .
Basically the requirement to send true or false values in string without being enclosed in quotes.
JSON String formatting Cobol
Re: JSON String formatting Cobol
Code: Select all
var j = '{"field1":"true","field2":"false"}';
var o = JSON.parse(j, (k, v) => v === "true" ? true : v === "false" ? false : v);
console.log(o);
I think this might help you with your problem.
-
- Similar Topics
- Replies
- Views
- Last post
-
- 1
- 4033
-
by Leixner
View the latest post
Thu Sep 15, 2022 3:33 am
-
-
Finding duplicate in variable lenght string in cobol
by kanipriya2785 » Fri Jun 17, 2022 10:02 pm » in IBM Cobol - 8
- 3474
-
by sergeyken
View the latest post
Wed Jun 22, 2022 3:10 am
-
-
-
Replace a string with another string with different length
by Devrana » Sun Jan 19, 2025 3:23 pm » in JCL - 1
- 1649
-
by sergeyken
View the latest post
Sun Jan 19, 2025 11:07 pm
-
-
-
Add a string depending on pattern
by Prasanna G » Mon Jul 05, 2021 8:48 am » in DFSORT/ICETOOL/ICEGENER - 1
- 1347
-
by Prasanna G
View the latest post
Mon Jul 05, 2021 11:07 am
-
-
- 4
- 2250
-
by sergeyken
View the latest post
Mon Jun 26, 2023 12:56 am