I want to add a new key into the pre-existing .json file.
- Is it possible to put the new key in the specific location? (ex) "SliceThickness" = 3 Add "SliceTiming" = 0.1 right after "SliceThickness" key
 How can I check the added one? I cannot see the added one in the pre-existing .json file.
- I'm using python3 with the Jupyter notebook.
 - pre-existing .json file (name: task-rest_bold.json) looks like this
 
In short, I want to put "SliceTiming" right after "SliceThickness". Additionally, I want to check in on the .json file, because with the code below, it says that SliceTiming has been successfully added, however, I could not find it on the "task_rest_bold.json" file.
{
  "AcquisitionMatrixPE": 63,
  "AcquisitionNumber": 5,
  "AcquisitionTime": "08:06:20.100000",
  "BodyPartExamined": "BRAIN",
  "CogAtlasID": "TODO",
  "CoilString": "SENSE-Head-8",
  "ConversionSoftware": "dcm2niix",
  "ConversionSoftwareVersion": "v1.0.20190410  GCC6.3.0",
  "DeviceSerialNumber": "4sEr9bzYud6E",
  "EchoTime": 0.030001,
  "EchoTrainLength": 59,
  "FlipAngle": 80,
  "ImageOrientationPatientDICOM": [1, 0, 0, 0, 1, 0],
  "ImageType": [
    "ORIGINAL",
    "PRIMARY",
    "M",
    "FFE",
    "M",
    "FFE"
],
  "ImagingFrequency": 127.779,
  "InPlanePhaseEncodingDirectionDICOM": "COL",
  "InstitutionName": "OHSU_MRI3",
  "MRAcquisitionType": "2D",
  "MagneticFieldStrength": 3,
  "Manufacturer": "Philips",
  "ManufacturersModelName": "Intera",
  "Modality": "MR",
  "PartialFourier": 0.936508,
  "PatientPosition": "HFS",
  "PercentPhaseFOV": 93.75,
  "PhaseEncodingAxis": "j",
  "PhaseEncodingSteps": 63,
  "PhilipsRWVIntercept": 0,
  "PhilipsRWVSlope": 1.22833,
  "PhilipsRescaleIntercept": 0,
  "PhilipsRescaleSlope": 1.22833,
  "PhilipsScaleSlope": 0.000766453,
  "PixelBandwidth": 2110,
  "ProtocolName": "Resting_State_fMRI",
  "ReconMatrixPE": 64,
  "RepetitionTime": 3.001,
  "SAR": 0.0630149,
  "ScanOptions": "FS",
  "ScanningSequence": "GR",
  "SequenceVariant": "SK",
  "SeriesDescription": "Resting_State_fMRI",
  "SeriesNumber": 501,
  "SliceThickness": 3.313,
  "SoftwareVersions": "3.2.1_3.2.1.1",
  "SpacingBetweenSlices": 3.313,
  "TaskName": "TODO: full task name for rest",
  "UsePhilipsFloatNotDisplayScaling": 1,
  "dcmmeta_affine": [
    [-3.3125, 0.0, 0.0, 106.49729919433594],
    [0.0, 3.3125, 0.0, -96.91033935546875],
    [0.0, 0.0, 3.3125, -38.010536193847656],
    [0.0, 0.0, 0.0, 1.0]
],
  "dcmmeta_reorient_transform": [
    [0.0, -1.0, 0.0, 63.0],
    [1.0, 0.0, 0.0, 0.0],
    [0.0, 0.0, -1.0, 47.0],
    [0.0, 0.0, 0.0, 1.0]
],
  "dcmmeta_shape": [64, 64, 48, 140],
  "dcmmeta_slice_dim": 2,
  "dcmmeta_version": 0.6,
  "global": {
    "const": {
      "AcquisitionDuration": 423.1409912109375,
      "AcquisitionMatrix": [64, 0, 0, 63],
      "AcquisitionNumber": 5,
      "BitsAllocated": 16,
      "BitsStored": 16,
      "BodyPartExamined": "BRAIN",
      "Columns": 64,
      "DiffusionBValue": 0.0
      }
   }
}
import json
# Loading .json file
with open('/home/rrt/MyProject/Nifti2/task-rest_bold.json', 'r') as f:
    json_data = json.load(f)
# Print .json file with indent
print(json.dumps(json_data,indent="\t"))
# Check if "SliceTiming" exists
if 'SliceTiming' not in json_data:
    TR = json_data["RepetitionTime"]
    nSlices = json_data["dcmmeta_shape"][3]
    TA = TR/nSlices
    # Calculate SliceTiming
    SliceTiming = [0:TA:TR]
# Put SliceTiming into the .json file
json_data["SliceTiming"]= SliceTiming
if "SliceTiming" in json_data:
    print(json_data["SliceTiming"])