Adrian_Star
(Adrian Starukiewicz)
November 17, 2020, 4:07pm
1
I want to translate pairs from dictionary (Key:Value) given like this or otherwise transparently:
to this:
Where “fields” is main object, and others string are objects too with they values.
And at the end I want to deserialize this JSON Object to string like this:
{"fields": {"project": {"key": "<projectkey>"}, "summary": "<temat>", "description": "<opis>", "assignee": {"name": "<assignee>"}, "issuetype": {"name": "<issuetype>"}, "customfield_11733": {"value": "Medium"}}}
I need this to configure request to JIRA and pass this JsonString to HttpClient.
Any ideas?
I have this solution in Chilkat code, but the library is paid and I want to replace this solution:
I would like to prepare a universal module where I could give different fields depending on the project.
SowmyaLeo
(Sowmya Sivakumar)
November 17, 2020, 4:44pm
2
@Adrian_Star
Please can you try using
Newtonsoft.Json.JsonConvert.SerializeObject(TheDictionaryVariable)
to see if it gives you the desired output.
1 Like
Adrian_Star
(Adrian Starukiewicz)
November 17, 2020, 4:48pm
3
I tried and Json looks like this:
{"fields.project.key":"<project key>","fields.summary":"<topic of issue>","fields.description":"<issue description>","fields.priority.id":"3","fields.assignee.name":"<assigne name>","fields.issuetype.name":"<issue type>"}
with is not the same as:
{"fields": {"project": {"key": "<projectkey>"}, "summary": "<temat>", "description": "<opis>", "assignee": {"name": "<assignee>"}, "issuetype": {"name": "<issuetype>"}, "customfield_11733": {"value": "Medium"}}}
SowmyaLeo
(Sowmya Sivakumar)
November 17, 2020, 4:58pm
4
Can you share the source dictionary screenshot please and how the values are added into it. I will have a look . Just a sample one will do.
Adrian_Star
(Adrian Starukiewicz)
November 17, 2020, 5:07pm
5
I haven’t created the source data and dictionary yet because I don’t know if it’s possible. Until now, I have relied on the data contained in the VB.NET code using the Chilkat library:
And let’s take the test data from the code above:
fields.project.key = KeyProject (As String Argument)
fields.summary = Topic (As String Argument)
fields.description = Description (As String Argument)
fields.assignee.name = Assing_To (As String Argument)
fields.issuetype.id = 3
fields.customfield_11733.id = “string”
fields.customfield_11728 = Date.toString (As String Argument)
SowmyaLeo
(Sowmya Sivakumar)
November 17, 2020, 6:01pm
6
5 Likes
Adrian_Star
(Adrian Starukiewicz)
November 17, 2020, 7:09pm
7
1 Like
SowmyaLeo
(Sowmya Sivakumar)
November 17, 2020, 7:29pm
8
Thank you very much Glad it helped. Yes for every Json Object, we build a dictionary and add it to the main dictionary.
Happy automation
1 Like
Adrian_Star
(Adrian Starukiewicz)
November 20, 2020, 8:58am
9
Sowmya I slightly tuned your solution to my needs to make it easier to enter data and process it into a result. I am posting a project for future interested people.
Dictionary_To_Json.7z (23,8 KB)
1 Like
system
(system)
Closed
November 23, 2020, 8:58am
10
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.