citrusframework / citrusframework/citrus
Json transformation with conditions
- Dominant language
- Java
- Stars
- 485
- Forks
- 155
- Avg merge
- 4d 22h
- Merged PRs (30d)
- 6
Description
**Citrus Version**
Latest
**Question**
I have a case where we are retrieving a large json and we need to change some fields based on some conditions.
We have a cucumber test with a table, and when certain conditions of that table apply we need to add or replace some values in the JOSN message to be send by citrus to the SUT.
Example table (original table contains more):
A | B | C | D
1 | true | abc | false
A is always mapped to some field
So when **B** is **true** we need to change a field in the JSON to another constant value, if **false** leave it as is.
I would like to be able to manipulate the JSON-string before sending it to the TestCaseRunner so I don't need to use the process(jsonPath().expression()). The process does not allow me to apply on condition. So I'm missing that part of functionallity to change the JSON based on some conditions (condition apply to certain fields to be changed or not). In XSLT we were able to apply some transformation based on conditions.
**What I've tried so far**
**Additional information**
Would it be possible to do without having to parse the same JSON multiple times (for each condition)?
Contributor guide
Research direction
Start by reviewing the process(jsonPath().expression()) entry point and the TestCaseRunner flow described in the issue, along with how the Cucumber table supplies values. Determine the scope of a conditional JSON transformation and how it could avoid parsing the same message for every condition; done should include a defined behavior and tests for conditional field changes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- testing
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100