Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

set datatype of JSON value

See original GitHub issue

User 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:

<send endpoint="configRequestEndpoint">
  <message type="json">
    <resource file="file:src/test/templates/json/api/config/saveGroupTrips.json"/>
    <element path="$.data.trips[*].sourceBits" value="000110"/>

This request should also be considered for boolean values.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

svettwercommented, Jan 17, 2019

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

elvinspcommented, Jan 17, 2019


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 the value parameter, the implementation has to be done in private 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 the translate function also into the traverseJsonData which would make tanslate 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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found