set datatype of JSON value
See original GitHub issueUser story
As the a tester I want to be able to define the datatype of my JSON values, when sending them to the SUT.
With version Citrus 2.7.8 it is not possible to set the datatype of an JSON value. Numbers will be automatically set as Integer/float and doesn’t give the tester the opportunity to set them as string.
Additional context
Initial Question: https://github.com/citrusframework/citrus/issues/538
<send endpoint="configRequestEndpoint">
<message type="json">
<resource file="file:src/test/templates/json/api/config/saveGroupTrips.json"/>
<element path="$.data.trips[*].sourceBits" value="000110"/>
</message>
</send>
This request should also be considered for boolean values.
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
JSON Data Types - W3Schools
Valid Data Types. In JSON, values must be one of the following data types: a string; a number; an object (JSON object); an...
Read more >JSON | Data Types - GeeksforGeeks
JSON supports mainly 6 data types: ... Object: It is a set of name or value pairs inserted between {} (curly braces).
Read more >JSON - DataTypes - Tutorialspoint
JSON - DataTypes, JSON format supports the following data types − ... It is an unordered set of name/value pairs. Objects are enclosed...
Read more >change json value's datatype in javascript - Stack Overflow
I have a JSON object with following values:
Read more >MySQL 8.0 Reference Manual :: 11.5 The JSON Data Type
Along with the JSON data type, a set of SQL functions is available to enable operations on JSON values, such as creation, manipulation,...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi Elvin,
thx for the information. I’ll definitely have a look until your are back. I am very unhappy that I can’t support you on this as much as you deserve. I am really very sorry for that! 😢 I am currently working hard to get the roadmap and
2.7.9
+2.8.0
released, in addition to customer projects, writing articles etc.Thx for all your patience with this! We really much appreciate your work on this issue! 👍 Have a good time then!
BR, Sven
Hi,
in my mind I’m almost finished with this. One thing that is left from my prespective is the adaption of
com.consol.citrus.variable.dictionary.json.JsonMappingDataDictionary
.At the moment it seems the data dictionary can only replace attributes to String. If it should be able to replace attributes to different datatypes, it leads to some hurdles.
The function
public <T> T translate(String jsonPath, T value, TestContext context)
would be the ideal place to do it so, but because it is a template function and the return value is depend on the datatype of thevalue
parameter, the implementation has to be done inprivate void traverseJsonData(JSONObject jsonData, String jsonPath, TestContext context)
to resolve the datatype of the value. That on the other hand would require to move the mapping strategy which is done in thetranslate
function also into thetraverseJsonData
which would maketanslate
obsolete. I haven’t done anything yet so there is no code to review this problem. But basically it is revolving around those two functions.Any way I won’t be available for a month, so I can only do this once I’m back in Mid February. Let me know what you think of this and the rest of the code.
BR Elvin