Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Insight JSON import - How do you refer to the body / header of the JSON in the Selector field

Deleted user January 12, 2022

Hi,

I'm struggling with the JSON import to Insight as the JSON I'm working with doesn't have an array for the header (the top level of the JSON). It looks something like this:

{
"attribute1" : "value1",
"attribute2" : "value2",
"attribute3" : "value3",
"attribute4" : "value4",
"attribute5" : {
"attribute6" : "value6",
"attribute7" : "value7",
"attribute8" : "value8" }
}

 Well, the JSON import forces me to include a value in the Selector field, as the field is mandatory.

In the case of the JSON above, a valid selector would be "attribute5", which would allow me to get the values for attributes 6, 7 and 8. But not the values of attributes 1,2, 3 or 4.

So, what is the way of referring in the Selector field of the header (top level of the JSON) so that the importer allows to get the entirety of the JSON in this case?

4 answers

1 vote
Björn Gullander
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 27, 2022

Hi,

You are required to have an array in the JSON file. Otherwise the import is quite useless :)

If you don't have a selector name for the first level in the JSON file you can set a dot (.) in the Selector field of the mapping configuration.

Björn

0 votes
Antreas Solou September 8, 2023

The only actual post that helps with the Selector and JSON Import of JIRA. The documentation regarding this, is very bad (it's not the only one), no examples, nothing. 
I will try and document my findings as well, hope this will be helpful for someone else out there. 

Requirements: 

Import a list of assets provided by a supplier into Multiple object types in Jira. All assets were in a single excel file with various columns at the top

No.

Description

Sales Date

Serial No.

Warranty Starting Date (Parts)

Warranty Ending Date (Parts)

 Sales Unit Price 

SOR

Sales Invoice

Device Type

123

An asset

 

12iueq79

1.1.1911

1.1.1911

€100.00

-

-

Laptop

125

An asset

 

12iueq78

1.1.1911

1.1.1911

€100.00

-

-

Monitor

Using 1 single Assets import (and not multiple ones with multiple csv files), have all assets imported in different objecttypes based on the Device Type column value.

Solution: 

At first I tried to do it with a CSV file but unfortunately the selector is not working for CSV Imports. 
So I went ahead to try and do this with a JSON Import. By converting my excel file into a JSON, I had 1 single array with all rows below. This was still not helpful, because from my understanding the selector is again not working on Attributes and only on Array values.
The next thing to do was to create a JSON file using the values of "Device Type" column as the keys, so each unique value would then be an array of objects within the JSON value.

{

   "Laptop": [

      {

         "No.": "123",

         "Description": "An Asset",

         "Sales Date": "",

         "Serial No.": "12iueq79",

         "Warranty Starting Date (Parts)": "1.1.1911",

         "Warranty Ending Date (Parts)": "1.1.1911",

         "Sales Unit Price": "€ 100.00",

         "SOR": "",

         "Sales Invoice": "",

      }
   ],
   "Monitor": [
      {
         "No.": "125",
         "Description": "An Asset",
         "Sales Date": "",
         "Serial No.": "12iueq78",
         "Warranty Starting Date (Parts)": "1.1.1911",
         "Warranty Ending Date (Parts)": "1.1.1911",
         "Sales Unit Price": "€ 100.00",
         "SOR": "",
         "Sales Invoice": "",
      }
    ]
}

I then searched for examples on how to syntax the selector wording for the import, without any luck. Fortunately I found this post, which helped a bit to clear things up.
I then used as the Selector value the name of array as plain text
Cap0ture.PNG
I am not sure my solution is optimal, but it is still a workable solution. 


I had never worked with a JSON File before, so the lack of documentation made this very difficult. The positive side is that I got to learn something new. :)

Hope the above will be helpful for someone in the future! 

0 votes
Sascha Zaluskowski
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 22, 2022

Hey everyone and sorry for bumping this old thread, but this is the first and only related thread regarding this topic and I figured it would be better to document it here in one place. 

I'm basically facing the similar problem as OP. I have a json that defines one object with a lot of attributes. Therefore it also doesn't start with an array, but with a single name. 

So far I was only able to use the array name for the selector, i.e. attribute1. I can then map attribute1_sub1 to insight fields. I could repeat this configuration for all defined arrays (attribute1, attribute2, etc) in the json but I would still be missing the Name field for this import and I have no idea how to work around that limitation. 

Granted, I'm not a json expert, but from what I gathered so far, this seems to be a valid json structure (not starting with an array). 

So I guess my question is: Is not possible to use a wildcard as the selector when using the json importer in insight? If it is possible, what is the syntax?

 

Thanks everyone in advance!

 

{

    "Name": "Here goes the name",
"attribute1": [
        {
            "attribute1_sub1": false,
            "attribute1_sub2": {
                "attribute1_sub2.1": 1,
                "attribute1_sub2.2": "1234-5678"
            },
            "attribute1_sub3": [],
            "attribute1_sub4": [
                {
                    "attribute1_sub4.1": "en-US",
                    "attribute1_sub4.2": "Choose one"
                }
            ]
        }
    ],
    "attribute2": {
        "attribute2_sub1": "EUR",
        "attribute2_sub2": [
            "EUR"
        ]
    },
    "attribute3": [
        {
            "attribute3_sub1": "en-US",
            "attribute3_sub2": "Commercial Description"
        },
        {
            "attribute3_sub3": "de-DE",
            "attribute3_sub4": "Kommerzielle Beschreibung"
        }
    ]
}
0 votes
Julia Gracia May 10, 2022

Hi did you find a fix for this?

Björn Gullander
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 11, 2022

There needs to be an array on top level like this to be able to add a list of items: 


[
{
"attribute1" : "value1",
"attribute2" : "value2",
"attribute3" : "value3",
"attribute4" : "value4",
"attribute5" : {
"attribute6" : "value6",
"attribute7" : "value7",
"attribute8" : "value8"
}
},
{
"attribute1" : "value11",
"attribute2" : "value22",
"attribute3" : "value33",
"attribute4" : "value44",
"attribute5" : {
"attribute6" : "value66",
"attribute7" : "value77",
"attribute8" : "value88"
}
}
]

Like Julia Gracia likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events