1
How do i convert an array to a container in json mapping
Question asked by Andrew Long - 9/28/2024 at 2:04 PM
Answered
I have an element inside of an array that I need to break out and convert into a container - the number of elements in the container is the size of the array.  Any ideas
ADL

8 Replies

Reply to Thread
0
Liquid Support Replied
Employee Post
Hi,

Can you please provide an example snippet of the input json document and expected output json document? 
And snippet of the json schema for the annotations and classes?

0
Andrew Long Replied
Input json:
 "annotators": [
        {
          "email": "...@...",
          "full_name": "Full Name"
        }
      ],
      "bounding_box": {
        "h": 43.0556,
        "w": 40.2778,
        "x": 16.92,
        "y": 36.0063
      },
      "id": "1e3467-789060-4d79-bc45d6-e30f8a149255",
      "name": "feat00",
      "properties": [],
      "reviewers": [
        {
          "email": "...@...",
          "full_name": "Full Name"
        }
      ],
      "slot_names": [
        "0"
      ],
      "updated_at": "2024-09-25T17:56:41"
    },
    {
      "annotators": [
        {
          "email": "...@...",
          "full_name": "Full Name"
        }
      ],
      "bounding_box": {
        "h": 31.1248,
        "w": 30.5162,
        "x": 101.5839,
        "y": 126.2494
      },
      "id": "81e5b7b1-ae54-469320-bc7e-0d22213840b7a5",
      "name": "feat01",
      "properties": [],
      "reviewers": [
        {
          "email": "...@...",
          "full_name": "Full Name"
        }
      ],
      "slot_names": [
        "0"
      ],
      "updated_at": "2024-09-25T17:56:48"
    },
    {
      "annotators": [
        {
          "email": "...@...",
          "full_name": "Full Name"
        }
      ],
      "bounding_box": {
        "h": 31.1248,
        "w": 30.5162,
        "x": 288.9458,
        "y": 98.0494
      },
      "id": "895696e472-685b-4317-845c74-dfb06b333bbc6",
      "name": "feat02",
      "properties": [],
      "reviewers": [
        {
          "email": "...@...",
          "full_name": "Full Name"
        }
      ],
      "slot_names": [
        "0"
      ],
      "updated_at": "2024-09-25T17:56:54"
    },
    {
      "annotators": [
        {
          "email": "...@...",
          "full_name": "Full Name"
        }
      ],
      "bounding_box": {
        "h": 31.1248,
        "w": 30.5162,
        "x": 315.0612,
        "y": 50.6877
      },
      "id": "42374e003f-04806-4456f-b4b4d-0ac86581363aa",
      "name": "large01",
      "properties": [],
      "reviewers": [
        {
          "email": "...@...",
          "full_name": "Full Name"
        }
      ],
      "slot_names": [
        "0"
      ],
      "updated_at": "2024-09-25T17:57:04"
    },

Output json:
{
"classes": {
        "0": "feat00",
        "1": "feat01",
        "2": "feat02",
        "3": "large01"
    }
 
"images": {
        "CAM1-img.png": {
            "class": [
                1
            ]
        },
        "CAM2img.png": {
           "class": [         
                  1
            ]
       }
}
}
ADL
0
Liquid Support Replied
Employee Post
First lets look at the schema for the output "classes". In order to validate the structure you have described you would need a schema that looks something like this.


{
"$schema": "http://json-schema.org/draft-04/schema#";,
"type": "object",
"properties": {
"classes": {
"type": "object",
"additionalProperties": {
"type": "string"
}
},
This says "classes" can have properties with any name (i.e. "1", "2", "3" etc), and that the content of each property has to be of type string.

We can then use this schema in the JSON Writer within our data mapper transformation. 
As you want the "classes" to get the index from position they appear in the input data we can use the Position component (this simply adds and index property to whatever you connect it to).
You can then create an 'additional property' on the output writer for every source item, we use the index of the item to form the property name, and the "name" as its value.

The result is
{
"classes": {
"1": "feat00",
"2": "feat01",
"3": "feat02",
"4": "large01"
}
}
The schemas and transform I created are in the zip

Note: There was a bug that prevents this transform from running correctly. This was fixed in version  20.7.16 which will be released on Monday (7th Oct 2024).

0
Liquid Support Replied
Employee Post
0
Andrew Long Replied
I appreciate the help, in trying to test it.
Iy wouldn't run with the version I had as stated, I tired to install the version posted above, and this install has failed a few times, with the following error log:

10/9/2024 11:15:37 AM - Microsoft VSIX Installer
10/9/2024 11:15:37 AM - -------------------------------------------
10/9/2024 11:15:37 AM - vsixinstaller.exe version:
10/9/2024 11:15:37 AM - 17.11.435+d5e02aaeb0
10/9/2024 11:15:37 AM - -------------------------------------------
10/9/2024 11:15:37 AM - Command line parameters:
10/9/2024 11:15:37 AM - C:\Program Files (x86)\Microsoft Visual Studio\Installer\resources\app\ServiceHub\Services\Microsoft.VisualStudio.Setup.Service\VSIXInstaller.exe,C:\Program Files (x86)\Liquid Studio\LiquidTechnologies.VsPlugin.2022.vsix
10/9/2024 11:15:37 AM - -------------------------------------------
10/9/2024 11:15:37 AM - Microsoft VSIX Installer
10/9/2024 11:15:37 AM - -------------------------------------------
10/9/2024 11:15:38 AM - Skipping product Microsoft.VisualStudio.Product.BuildTools (df066d08) since it does not support extensions
10/9/2024 11:15:38 AM - Initializing Install...
10/9/2024 11:15:38 AM - Searching for applicable products...
10/9/2024 11:15:38 AM - Found installed product - Visual Studio Community 2019
10/9/2024 11:15:38 AM - Found installed product - Global Location
10/9/2024 11:15:38 AM - Extension Details...
10/9/2024 11:15:38 AM -     Identifier         : LiquidTechnologies.VsPlugin.F7E297E5-FF4E-4379-90B3-A9CA08172022
10/9/2024 11:15:38 AM -     Name               : Liquid Studio
10/9/2024 11:15:38 AM -     Author             : Liquid Technologies Ltd
10/9/2024 11:15:38 AM -     Version            : 20.7.16
10/9/2024 11:15:38 AM -     Description        : Graphical XML Schema (XSD) Editor.
Graphical JSON Schema Editor.
Graphical WSDL Editor.
Web Service Test Client.
XPath Results Viewer.
  
10/9/2024 11:15:38 AM -     Locale             : en-US
10/9/2024 11:15:38 AM -     MoreInfoURL        : <had to remove this to post>
10/9/2024 11:15:38 AM -     InstalledByMSI     : False
10/9/2024 11:15:38 AM -     SupportedFrameworkVersionRange : [4.7.2,)
10/9/2024 11:15:38 AM -     SignatureState     : Unsigned
10/9/2024 11:15:38 AM -     Supported Products : 
10/9/2024 11:15:38 AM -         Microsoft.VisualStudio.Community
10/9/2024 11:15:38 AM -             Version : [17.0,18.0)
10/9/2024 11:15:38 AM -             ProductArchitecture : amd64
10/9/2024 11:15:38 AM -         Microsoft.VisualStudio.Pro
10/9/2024 11:15:38 AM -             Version : [17.0,18.0)
10/9/2024 11:15:38 AM -             ProductArchitecture : amd64
10/9/2024 11:15:38 AM -         Microsoft.VisualStudio.Premium
10/9/2024 11:15:38 AM -             Version : [17.0,18.0)
10/9/2024 11:15:38 AM -             ProductArchitecture : amd64
10/9/2024 11:15:38 AM -         Microsoft.VisualStudio.Enterprise
10/9/2024 11:15:38 AM -             Version : [17.0,18.0)
10/9/2024 11:15:38 AM -             ProductArchitecture : amd64
10/9/2024 11:15:38 AM -         Microsoft.VisualStudio.Ultimate
10/9/2024 11:15:38 AM -             Version : [17.0,18.0)
10/9/2024 11:15:38 AM -             ProductArchitecture : amd64
10/9/2024 11:15:38 AM -     References         : 
10/9/2024 11:15:38 AM -     Prerequisites      : 
10/9/2024 11:15:38 AM -         -------------------------------------------------------
10/9/2024 11:15:38 AM -         Identifier   : Microsoft.VisualStudio.Component.CoreEditor
10/9/2024 11:15:38 AM -         Name         : Visual Studio core editor
10/9/2024 11:15:38 AM -         Version      : [14.0,)
10/9/2024 11:15:38 AM - Signature Details...
10/9/2024 11:15:38 AM -     Extension is not signed.
10/9/2024 11:15:38 AM - VSIXInstaller.NoApplicableSKUsException: This extension is not installable on any currently installed products.
   at VSIXInstaller.ExtensionService.GetInstallableDataImpl(String vsixPath, String extensionPackParentName, Boolean isRepairSupported, IStateData stateData, IEnumerable`1& skuData)
   at VSIXInstaller.ExtensionService.GetInstallableData(String vsixPath, String extensionPackParentName, Boolean isRepairSupported, IStateData stateData, IEnumerable`1& skuData)
   at VSIXInstaller.ExtensionPackService.IsExtensionPack(IStateData stateData, Boolean isRepairSupported)
   at VSIXInstaller.ExtensionPackService.ExpandExtensionPackToInstall(IStateData stateData, Boolean isRepairSupported)
   at VSIXInstaller.App.Initialize(Boolean isRepairSupported)
   at VSIXInstaller.App.Initialize()
   at System.Threading.Tasks.Task`1.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()

Is there a problem with the new installer?


ADL
0
Liquid Support Replied
Employee Post Marked As Answer
The error implies there is an issue with your version of Microsoft Visual Studio.

Please uncheck the boxes for Microsoft Visual Studio extensions during install.

Please see:
0
Andrew Long Replied
Appreciate the help,
I have a question about where I specify the filepath as an input for the compiled application - is there a video or some documentation as to how to set up the CLI
ADL
0
Liquid Support Replied
Employee Post

Reply to Thread