[enter image description here][1]my expected output is below,
{
"TicketNo":6255,
"Name": "Issac",
"Age": 20,
"Code": "IND354"
}
but I am getting below while transforming the db payload to Json
{
"TicketNo": [
6255
],
"Name": [
"Issac"
],
"Age": [
20
],
"Code": [
"IND354"
]
}
attaching my RAML, datatype and values body:
application/json:
type: Flight
examples:
!include outfile.raml
#%RAML 1.0 DataType
type: object
properties:
TicketNo: integer
Name: string
Age: integer
Code: string
--outfile.raml---
#%RAML 1.0 NamedExample
value:
TicketNo: 1
Name: Issac
Age: 29
Code: IND354
payload from database [1]: https://i.stack.imgur.com/hm01n.png
The database query is returning an array of objects. In your example it is returning an array of 1 element. It seems that you are trying to transform the payload directly without considering it is an array, so your transformation returns arrays for each value.
One way to implement the transformation is to select only the first element of the array. This assumes that you only want one object in the response and the query returns at least one object in the response array.