Hello.

I try on JSP to implement the unloading of the results of 2 select into one JSON.

<c:set var="SCRIPT_FailedCount"> SELECT 1 as MEAS_VALUE, 'First_Table' from dual union SELECT 2 as MEAS_VALUE, 'First_Table' from dual union SELECT 3 as MEAS_VALUE, 'First_Table' from dual union SELECT 4 as MEAS_VALUE, 'First_Table' from dual </c:set> <c:set var="SCRIPT_SucceededCount"> SELECT 40 as MEAS_VALUE, 'Second_Table' from dual union SELECT 30 as MEAS_VALUE, 'Second_Table' from dual union SELECT 20 as MEAS_VALUE, 'Second_Table' from dual union SELECT 10 as MEAS_VALUE, 'Second_Table' from dual </c:set> <sql:query var="SCRIPT_FailedCount" dataSource="jdbc/Oracle"> ${SCRIPT_FailedCount} </sql:query> <sql:query var="SCRIPT_SucceededCount" dataSource="jdbc/Oracle"> ${SCRIPT_SucceededCount} </sql:query> <%@ taglib prefix="json" uri="http://www.atg.com/taglibs/json" %> <c:set var="json_text" scope="application"> <json:object> <json:array name="FailedCount" prettyPrint="false"> <c:forEach var="row" items="${SCRIPT_FailedCount.rows}"> <json:object> <json:property name="FailedCount_MEAS_VALUE" value="${row.MEAS_VALUE}"/> </json:object> </c:forEach> </json:array> <json:array name="SucceededCount" prettyPrint="false"> <c:forEach var="row" items="${SCRIPT_SucceededCount.rows}"> <json:object> <json:property name="SucceededCount_MEAS_VALUE" value="${row.MEAS_VALUE}"/> </json:object> </c:forEach> </json:array> </json:object> </c:set> 

the result is this JSON

 { "FailedCount":[{"FailedCount_MEAS_VALUE":1}, {"FailedCount_MEAS_VALUE":2}, {"FailedCount_MEAS_VALUE":3}, {"FailedCount_MEAS_VALUE":4}], "SucceededCount":[{"SucceededCount_MEAS_VALUE":10}, {"SucceededCount_MEAS_VALUE":20}, {"SucceededCount_MEAS_VALUE":30}, {"SucceededCount_MEAS_VALUE":40}] } 

Tell me how, on JSP, combine 2 select results to get a generic JSON of this type:

 { "Failed_Succeeded_Count":[ {"FailedCount_MEAS_VALUE":1,"SucceededCount_MEAS_VALUE":10}, {"FailedCount_MEAS_VALUE":2, "SucceededCount_MEAS_VALUE":20}, {"FailedCount_MEAS_VALUE":3, "SucceededCount_MEAS_VALUE":30}, {"FailedCount_MEAS_VALUE":4, "SucceededCount_MEAS_VALUE":40}] } 

  • Is there a connection between the entries FailedCount_MEAS_VALUE ": 1 and" SucceededCount_MEAS_VALUE ": 10? That is, how are the tables (first and second) related? By time? By some fields? - Chubatiy
  • The number of entries FailedCount_MEAS_VALUE and SucceededCount_MEAS_VALUE will be the same, in time they will also be the same - Nikolay Baranenko

0