Click here to Skip to main content
14,838,357 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
How can i convert sql qury results to jsaon data for parsing
Please share the examples

What I have tried:

How can i convert sql qury results to jsaon data for parsing 
Please share the examples 
Posted
Updated 20-Jan-21 10:38am
Comments
k5054 20-Jan-21 13:19pm
   
You'll need to give us some more information, please. What OS and what SQL database engine are you using? Take a look at your database documentation, many databases now can produce JSON output, rather than a text table or CSV values.

1 solution

here[^]

SELECT id, firstName AS "info.name", lastName AS "info.surname", age, dateOfBirth AS dob
FROM People
FOR JSON PATH;


will select JSON
   
v2
Comments
Member 15051539 21-Jan-21 8:22am
   
I have query results and unix shell script to parse the sql output into json data.
QUERY:select username, account_status, expiry_date from dba_users where lower(username) not like '%sys%';
I want to parse the above quey out put to json data .

The concept is alert the password expire users
Can you pls help me that
Christian Graus 21-Jan-21 15:19pm
   
As I showed you, you can select JSON data right from the DB. Otherwise you can grab your data set and string mash JSON
Member 15051539 21-Jan-21 19:01pm
   
Thank you .im in first phase learning .Could please help some examples .
Here is the sample input

Account_name sttus Expiry_date
TOAD ,OPEN ,
ASG ,EXPIRED & LOCKED ,18-AUG-15
OOCM ,EXPIRED & LOCKED ,18-AUG-15
AS$NULL ,EXPIRED & LOCKED ,18-AUG-15
DFMUSER ,EXPIRED & LOCKED ,18-AUG-15
ANONYMOUS ,EXPIRED & LOCKED ,18-AUG-15
DBASDSNMP ,EXPIRED & LOCKED , 18-AUG-15
A_INTERNAL ,EXPIRED & LOCKED ,18-AUG-15
OUTLN ,EXPIRED & LOCKED ,18-AUG-15
Christian Graus 21-Jan-21 19:14pm
   
The code I gave you will select JSON from the database

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900