title: Data Weave transformatio expcetion on JSON inbound message to Json outbound message
body: <p>I am trying to do the following transformation in data weave </p>
  
  <pre><code>%dw 1.0
  %input in application/json
  %output application/json
  ---
  flowVars["xyz"]
  </code></pre>
  
  <p>"xyz" variable is itself a JSON object. I ask this because I need to merge two payload(payload + variable) as one JSON object , where this is the first step.</p>
  
  <p>Also If I provide Payload instead of flowVars["xyz"] then I get the same error.The Payload is also of the same type JSON object.</p>
  
  <p>The following is the stack trace </p>
  
  <pre><code>Root Exception stack trace:
  com.mulesoft.weave.writer.json.JsonInvalidStructureException: JSON can only have one top-level value and that value can only be either an array or an object
  at com.mulesoft.weave.writer.json.JsonWriter.value(JsonWriter.scala:44)
  at com.mulesoft.weave.writer.json.JsonWriter.value(JsonWriter.scala:36)
  at com.mulesoft.weave.engine.Engine.internalExecute(Engine.scala:88)
  at com.mulesoft.weave.engine.Engine.execute(Engine.scala:53)
  at com.mulesoft.weave.engine.Engine.execute(Engine.scala:181)
  at com.mulesoft.weave.mule.WeaveMessageProcessor$WeaveOutputHandler.write(WeaveMessageProcessor.scala:198)
  at org.mule.transformer.simple.ObjectToString.createStringFromOutputHandler(ObjectToString.java:102)
  at org.mule.transformer.simple.ObjectToString.doTransform(ObjectToString.java:56)
  at org.mule.transformer.AbstractTransformer.transform(AbstractTransformer.java:415)
  at org.mule.transformer.AbstractTransformer.transform(AbstractTransformer.java:366)
  at org.mule.DefaultMuleMessage.transformMessage(DefaultMuleMessage.java:1606)
  at org.mule.DefaultMuleMessage.applyAllTransformers(DefaultMuleMessage.java:1509)
  at org.mule.DefaultMuleMessage.applyTransformers(DefaultMuleMessage.java:1487)
  at org.mule.DefaultMuleMessage.applyTransformers(DefaultMuleMessage.java:1479)
  at org.mule.transformer.AbstractTransformer.process(AbstractTransformer.java:114)
  at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
  at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:107)
  at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
  at org.mule.processor.BlockingProcessorExecutor.executeNext(BlockingProcessorExecutor.java:94)
  at org.mule.processor.BlockingProcessorExecutor.execute(BlockingProcessorExecutor.java:56)
  at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
  at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
  at org.mule.processor.BlockingProcessorExecutor.executeNext(BlockingProcessorExecutor.java:94)
  at org.mule.processor.BlockingProcessorExecutor.execute(BlockingProcessorExecutor.java:56)
  at org.mule.processor.AsyncInterceptingMessageProcessor.process(AsyncInterceptingMessageProcessor.java:102)
  at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
  at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:107)
  at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
  at org.mule.processor.BlockingProcessorExecutor.executeNext(BlockingProcessorExecutor.java:94)
  at org.mule.processor.BlockingProcessorExecutor.execute(BlockingProcessorExecutor.java:56)
  at org.mule.construct.DynamicPipelineMessageProcessor.process(DynamicPipelineMessageProcessor.java:55)
  at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
  at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:107)
  at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
  at org.mule.processor.BlockingProcessorExecutor.executeNext(BlockingProcessorExecutor.java:85)
  at org.mule.processor.BlockingProcessorExecutor.execute(BlockingProcessorExecutor.java:56)
  at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
  at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
  at org.mule.processor.BlockingProcessorExecutor.executeNext(BlockingProcessorExecutor.java:94)
  at org.mule.processor.BlockingProcessorExecutor.execute(BlockingProcessorExecutor.java:56)
  at org.mule.interceptor.AbstractEnvelopeInterceptor.processBlocking(AbstractEnvelopeInterceptor.java:58)
  at org.mule.processor.AbstractRequestResponseMessageProcessor.process(AbstractRequestResponseMessageProcessor.java:47)
  at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
  at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:107)
  at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
  at org.mule.processor.BlockingProcessorExecutor.executeNext(BlockingProcessorExecutor.java:94)
  at org.mule.processor.BlockingProcessorExecutor.execute(Blocking...
  </code></pre>
  
  <hr>
  
  <p>Let me know if more information is needed</p>