Search code examples
siddhi

json:getString vs map:get, which is better?


I'm working with a Siddhi App getting values from a kafka source and sending those data to a kafka sink after some logic process, I'm getting the data with the json:getString function and I asked to test the performance. So, I wanna know if there is a advantage with respect to map:get or how can I improve the performance of my siddi app?


Solution

  • Using execution-json extension’s json:getString uses JSON path to extract the string value from a JSON message, whereas using executions-map extension you can convert JSON as a key-value pair and then retrieve the data from it. We have tried to optimize both the cases, but in general, If you want to extract just a few values json:getString will be a better option while if you need to extract almost all the values concerting in to map would be better.

    However, as you are concerned on the performance I highly recommend you to decide after doing a perf test using both methods. As the performance depends on the usecase, do share a sample message and the needed transformations if you need more assistant.