0

I would like to get results into jquery datatables via JSON. The page is written in JSP.

The table contain a special field with XML string:

{ 
  "sEcho": 1, 
  "iTotalRecords": "3800", 
  "iTotalDisplayRecords": "3800", 
  "aaData": [ [ "16.12.2013 14:14:55 GMT", 
                "Unknown", 
                "Unknown", 
                "", 
                "26414321279", 
                "ci1387203295280.36875276@czchols2138_te", 
                "<?xml version="1.0" encoding="UTF-8"?> <ExtendedEventContent> <Transport_Failure> <Error>Incomplete data received</Error> <Transport_Error>com.cyclonecommerce.tradingengine.transport.FileNotFoundException: 550 TEST.xml: The system cannot find the file specified. ; command=RETR TEST.xml</Transport_Error> </Transport_Failure> </ExtendedEventContent> ", 
                "" ] ,
               ...

datatables initiation script:

<script>
  $(document).ready(function() {
    $('#failedDetails').dataTable( {
      "bStateSave": true,
  "bProcessing": true,
  "bServerSide": true,
      "sAjaxSource": "./inc_failed_details_json.jsp",
  "aLengthMenu": [[10, 50, 100, -1], [10, 50, 100, "All"]],
      "iDisplayLength": 10,
  "aaSorting": [[ 0, "asc" ]]
 } );

} );

I am getting of course error:

... JSON data from server could not be parsed. This is caused by a JSON formatting error.

The data are gathered from Oracle DB. I have tried to use replace for the XML value by:

(select replace(max(details), '"', '\"') from cyclone.messageevents where messageoid = m.oid) Details,
 "<?xml version=\"1.0\" encoding=\"UTF-8\"?> <ExtendedEventContent> <Reason> <Event>Messaging.Message.Duplicate.Message</Event> </Reason> </ExtendedEventContent> "

but with same result.

Exists anybody who can help with that?

1 Answer 1

1

you need to convert " " into ' ' in your XML field

i have created jsfiddle to DEMO

var obj1 = {};
obj1.data = "Name"
obj1.xmlData = "<?xml version='1.0' encoding='UTF-8'?> <ExtendedEventContent> <Transport_Failure> <Error>Incomplete data received</Error> <Transport_Error>com.cyclonecommerce.tradingengine.transport.FileNotFoundException: 550 TEST.xml: The system cannot find the file specified. ; command=RETR TEST.xml</Transport_Error> </Transport_Failure> </ExtendedEventContent>"

$(document).ready(function() { 
    $('.test').html(JSON.stringify(obj1));
});
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you Patel. Nice solution. Even I have resolved that problem by regexp_replace(to_char(wm_concat(rejectedreason)), '[[:cntrl:]]|\\') while gathering data from DB I will definitely reuse your solution for another pain-point :) Thanks again Regards Rudo

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.