The TIBCO Platform is a real-time, composable data platform that will bring together an evolving set of your TIBCO solutions - and it's available now!
A chart showing the TIBCO Platform vision
Jump to content
Forums
Ask questions and gain insight from discussions

Recommended Posts

Posted

If someone has a good tutorial link, link or has answer that would be excellent. I need JSON output similar to this:

{

"sample_json_output":

{ "status" : 1,

"status_message" : "NULL",

"result" : { "details": { "id" : 1234,

"title" : "A Title",

"description": "Descriptive text here"

}

},

"empty_array": []

}

}

I don't know xsd formatting at all, and xml only a little more. The CIS documentation is too simplified to describe this, and I'm unable to find a solution on the web.

Posted

Try this ins a stored procedure.

OUT status INT,OUT status_message VARCHAR(255),OUT result CURSOR ( id INT, title VARCHAR(255), description TEXT),OUT empty_array CURSOR()

In the Web Service you can update the name insread of the output saying StoreProcesureStatus.

If the array is empty it will show empty_array = NULL in the json output.

 

I hope this helps!

Posted

Close, but not the result I'm looking for. Here's what I got when I published the procedure:

{ "p_test_empty_array": { "status": 1, "status_message": "", "result": { "data_set_details": [ { "id": 1234, "name": "blarg", "description": "nonsense junk here", "class_name": "low" } ] }, "empty_array": "" }}

The empty_array isn't an array, it's an empty string. The developers who consume this REST service expect to see: "empty_array": [] -- open/close brackets. Or, they would also accept no "empty_array" attribute at all if no data is returned for that part.

A Cisco consultant here said it wasn't possible to get the former without and XSD (definition set), thus the reason for my post.

  • 3 months later...
Posted

I figured out how to remove the empty array element by editing the XQuery for the transformation. It looks for an empty string in one of the array's elements - if null it ends there, otherwise it prints out all of the elements.

{ let $nodes := ( let $inputs := (if (empty($in_name)) then "NULL" else concat(concat("'",$in_name), "'") cast as xs:string) let $query := concat( "select status,status_message,id,title,description,characterization,first_name,last_name,nickname,occupation,user_id from /shared/snipped_to_protect_the innocent(", concat( string-join($inputs,","), ")")) let $data_set_details1 := composite:executeQuery($query)//result for $data_set_details in $data_set_details1 return element ns1:data_set_details { element ns1:status {$data_set_details/status/text()}, element ns1:status_message {$data_set_details/status_message/text()}, let $nodes := ( element ns1:result { let $nodes := ( element ns1:data_set_detail { element ns1:id {$data_set_details/id/text()}, element ns1:title {$data_set_details/title/text()}, element ns1:description {$data_set_details/description/text()}, element ns1:characterization {$data_set_details/characterization/text()}, for $data_set_details in $data_set_details1 return ----> if (empty($data_set_details/user_id/text())) then

  • 3 weeks later...
Posted
The web service I'm working to fix is a JSON REST service, so yes, the array is not included in the JSON response if the element I examine is null, otherwise the array is shown when there is data.
  • 1 month later...
Posted

A little late,

you should be able to manually create an XSD or use something like xmlspy to define an XSD for you if you have an example XML output.

We've had to manually configure and XSD to ensure a consistent format.

Looks like you may already have an answer but hope it helps for future reference.

  • 2 years later...
  • 4 weeks later...
Posted

I'm also looking for a similar solution for an XML web service published in DV.  The response does not include an empty array object when there is no data, but it really should.  It looks like 

 

"array_object": []

 

when it should look like

 

"array_object": [{}]

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...