`fromjson` method in templates
chason-choate opened this issue · 3 comments
We have a use-case where we are using the reactive consumer and want to alter the JSON emitted from the producer.
Therefore i'd propose adding a fromjson
method to mirror the tojson
method. This gives templates more flexibility in how it deals with data.
Can you elaborate? Maybe add example with config how would it look?
Sure thing, here is how we are using it:
Our reactive consumer config:
- name: Kafka Actors
type: kafka
address: kafka:9092
actors:
- name: reactive
consume:
queue: input-topic
produce:
queue: output-topic
value: '@output-response.json.hbs'
And the output-response.json.hbs
template:
NOTE: We've edited the hbs/methods.py
file to add this fromjson
method.
{{ tojson (jsonPath (fromjson consumed.value) '$.payload') }}
If you already have a working implementation, can you create a PR that contains it? I'd be happy to review and accept it.
Note: it would be great if PR would also contain a documentation piece for this function.