help in spliting the query result
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2024 01:55 PM - edited 03-19-2024 02:01 PM
I have an output as
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2024 02:07 PM
Hi @JPSS,
To convert the given output into JavaScript variables `a` and `b`, you can use string manipulation techniques. Here's a simple way to achieve this using Javascript:// Assuming your output is stored in a variable called 'output'
var output = '"68e911851b2be050ccbb6202b24bcbde","Not found"';
// Remove the quotes and split the string by comma
var parts = output.replace(/"/g, "").split(",");
// Assign values to variables a and b
var a = parts[0];
var b = parts[1];
console.log("var a=" + a + ";");
console.log("var b=" + b + ";");
```
This will output:
var a=68e911851b2be050ccbb6202b24bcbde;
var b=Not found;
Make sure to adjust the `output` variable according to your actual input.
Please hit helpful and accept this as a solution if solves your queries.
Regards: Aqib
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2024 02:22 PM
@JPSS , Two ways you can do this , Store your values into an Array[]
var a [‘example’,’split’]
var value1=a[0];
var value2=a[1];
If you want to use Split Functionality
You need to use below
var a = (‘example’,’spli’);
Var b = a.split(‘,’);
You can modify as per your need
Regards,
Shyamkumar
Regards,
Shyamkumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2024 02:27 PM
Hi @JPSS ,
You can try below code to fetch jason values from key value pair,
var obj = {"business_application":"68e911851b2be050ccbb6202b24bcbde","service_offering":"Not found"};
var str =JSON.stringify(obj);
var parser = new JSONParser();
var result = parser.parse(str);
var a = result.business_application;
var b = result.service_offering;
//gs.print('a ' + a);
//gs.print('b ' + b);
Please mark this comment as Correct Answer/Helpful if it helped you.
Regards,
Swathi Sarang