Hitachi Content Intelligence​

 View Only

 I need to read a JSON with information arrays.

  • Object Storage
  • Hitachi Content Intelligence HCI
Nils Boman's profile image
Nils Boman posted 05-18-2021 11:47

The JSON looks like this

 

[CODE]

{

  "DD21-004477": [

    {

      "referensnummer": "8597351298",

      "date": "null",

      "runtype": "null",

      "age": "null",

      "gender": "null",

      "lab_reference": "null",

      "postalcode": "00",

      "ct_value": "35"

    }

  ],

  "DC21-031196": [

    {

      "referensnummer": "null",

      "date": "null",

      "runtype": "null",

      "age": "null",

      "gender": "null",

      "lab_reference": "null",

      "postalcode": "00",

      "ct_value": "61"

    }

  ]

}

[/CODE]

 

 

Second issue is that need to connect the first number in the JSON with another data source and preffebly in the same index. I would kindly ask for some pointers in what to do :)

 

Thanks!


#HitachiContentIntelligenceHCI
William Jansen van Nieuwenhuizen's profile image
William Jansen van Nieuwenhuizen

Hello Neils

 

Shouldn't be too difficult with something like python. If you can show what you want to do, it should be a few lines of code. To loop through the fiels you could do something like:

import json my_list_of_arrays = {  "DD21-004477": [ { "referensnummer": "8597351298", "date": "null", "runtype": "null", "age": "null", "gender": "null", "lab_reference": "null", "postalcode": "00", "ct_value": "35" } ], "DC21-031196": [ { "referensnummer": "null", "date": "null", "runtype": "null", "age": "null", "gender": "null", "lab_reference": "null", "postalcode": "00", "ct_value": "61" } ]} for each_array in my_list_of_arrays.keys(): # Check something print something print("My array: {}".format(each_array)) print("Data of Array: {}".format(json.dumps(my_list_of_arrays[each_array][0], indent=4)))

 Output:

My array: DD21-004477Data of Array: { "referensnummer": "8597351298", "date": "null", "runtype": "null", "age": "null", "gender": "null", "lab_reference": "null", "postalcode": "00", "ct_value": "35"}My array: DC21-031196Data of Array: { "referensnummer": "null", "date": "null", "runtype": "null", "age": "null", "gender": "null", "lab_reference": "null", "postalcode": "00", "ct_value": "61"}

 

Nils Boman's profile image
Nils Boman

Hi and thanks for the response. I've tinkered around with this but wanted to have something done within HCI and not external scrips. In the end the solution was to change the output from the DNA sequencing to CSV instead of JSON to solve this problem.