Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TemplateBuilder issue with Siddhi objects and Json mapper custom payload mapper #1623

Open
pierre-borckmans opened this issue Feb 13, 2020 · 0 comments

Comments

@pierre-borckmans
Copy link
Contributor

pierre-borckmans commented Feb 13, 2020

Description:
The following app will produce proper json format for the context field:

@App:name("Test siddhi objects json mapping")
define trigger EverySecond at every 1 second;
@sink(type='log', @map(type = 'json'))
define stream LogStream (context object);
from EverySecond select 
  map:create(
    "x",123,
    "y","abcd"
  ) as context      
insert into LogStream;

This will output the following

{ "context": { "x": 123, "y": "abcd" } } 

However, when using a @payload in the mapper as follows, the context object is not formatted as proper json:

@App:name("Test siddhi objects json mapping")
define trigger EverySecond at every 1 second;
@sink(type='log', @map(type = 'json', 
    @payload("""{
  "context": {{context}}   
}
""")
  )
)
define stream LogStream (context object);
from EverySecond
select 
  map:create(
    "x",123,
    "y","abcd"
  ) as context      
insert into LogStream;

will output the following:

{ "context": {x=123, y=abcd}, }

I understand this might be complex to fix as the TemplateBuilder is unaware of which mapper (json in this case) is used.

At the end of the day, what I need is a way to produce custom json output from a stream, while being able to use siddhi objects formatted as json.
Note that this is somewhat related to siddhi-io/siddhi-map-json#81 because if I could use the same map as in a source, I would not need a custom @payload

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant