You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: xASL_bids_JsonCheck.m
    path of file: ./repos/ExploreASL/Functions/BIDS
    
    the code of the file until where you have to start completion: function [jsonOut,reportOut] = xASL_bids_JsonCheck(jsonIn,fileType)

    
function [jsonOut,reportOut] = xASL_bids_JsonCheck(jsonIn,fileType)
%xASL_bids_JsonCheck Goes through the JSON structure before saving it and ensures that it fits the ASL-BIDS format
%
% FORMAT: jsonOut = xASL_bids_JsonCheck(jsonIn,fileType)
%
% INPUT:
%   jsonIn     - JSON with the input fields (REQUIRED)
%   fileType   - 'ASL' or 'M0' when the input and output is ASL-BIDS, empty for normal BIDS (REQUIRED)
%
% OUTPUT: 
%   jsonOut   - ordered and checked JSON structure
%   reportOut - struct to report about bids depdency related issues
%
% -----------------------------------------------------------------------------------------------------------------------------------------------------
% DESCRIPTION:
% It checks the existence of all BIDS fields, removes superfluous fields, checks all the conditions and orderes
% the structure on the output. It works according to the normal BIDS, or ASL-BIDS definition
%
% EXAMPLE: n/a
%
% __________________________________
% Copyright 2015-2021 ExploreASL

% Create an empty output structure and a structure with fields to delete
jsonOut = struct;
jsonRemove = struct;
reportOut = struct;

bidsPar = xASL_bids_Config();

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Remove fields not belonging to BIDS

% Remove certain empty fields
for iField = 1:length(bidsPar.listRemoveIfEmpty)
    if isfield(jsonIn,bidsPar.listRemoveIfEmpty{iField})
        if isempty(jsonIn.(bidsPar.listRemoveIfEmpty{iField}))
            jsonRemove.(bidsPar.listRemoveIfEmpty{iField}) = '';
        end