All files / output zcl_abapgit_json_path.clas.locals.mjs

84.77% Statements 323/381
57.73% Branches 56/97
30.76% Functions 16/52
84.77% Lines 323/381

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 3811x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 1x 3x 3x 3x 1x     1x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 2x 2x 2x 2x 2x 2x 2x 2x 2x 4x 4x 1x     1x 4x 4x 4x 4x 4x 4x 4x 4x 4x 1x     1x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x     9x 9x 9x 2x 2x 9x 4x 4x 4x 4x 7x 3x 3x 3x 3x 3x 3x 3x 2x 3x 1x 1x 1x 1x 3x 9x 1x     1x 7x 7x 7x 7x 7x 7x 7x 7x 1x     1x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x               2x 12x 12x 12x 12x 2x 2x 1x 23x 23x 23x 23x 23x 23x 23x 1x 34x 34x 34x 34x 34x 34x 34x 1x 48x 48x 48x 48x 48x 48x 48x 1x 15x 15x 15x 15x 15x 15x 15x 15x 15x 15x 15x 15x 1x 1x 15x 3x 3x 3x 3x 3x 3x 3x 3x 15x 5x 5x 11x 2x 2x 6x 4x 4x 4x 15x 1x 22x 22x 22x 22x 22x 22x 22x 22x 22x 22x 22x 22x 22x 2x 2x 22x               22x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 20x 1x 1x 14x 13x 13x 13x 22x 1x 9x 9x 9x 9x 9x 9x 9x 9x 1x     1x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x               3x 7x 7x 3x 3x 4x 4x 7x               4x 4x 7x               7x 3x 3x 3x               3x 3x 1x     1x 7x 7x 7x 7x 7x 1x 1x 1x 6x 7x 1x 1x 1x 5x 7x 1x 1x 1x 4x 7x 1x 1x 1x
const {cx_root} = await import("./cx_root.clas.mjs");
// zcl_abapgit_json_path.clas.locals_imp.abap
class lcl_json_path {
  static INTERNAL_TYPE = 'CLAS';
  static INTERNAL_NAME = 'CLAS-ZCL_ABAPGIT_JSON_PATH-LCL_JSON_PATH';
  static IMPLEMENTED_INTERFACES = [];
  static ATTRIBUTES = {};
  static METHODS = {"IS_ARRAY": {"visibility": "I", "parameters": {"RV_RESULT": {"type": () => {return new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"});}, "is_optional": " "}, "IO_READER": {"type": () => {return new abap.types.ABAPObject({qualifiedName: "IF_SXML_READER", RTTIName: "\\INTERFACE=IF_SXML_READER"});}, "is_optional": " "}}},
  "IS_STRING_OPEN": {"visibility": "I", "parameters": {"RV_RESULT": {"type": () => {return new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"});}, "is_optional": " "}, "IO_READER": {"type": () => {return new abap.types.ABAPObject({qualifiedName: "IF_SXML_READER", RTTIName: "\\INTERFACE=IF_SXML_READER"});}, "is_optional": " "}}},
  "IS_OBJECT": {"visibility": "I", "parameters": {"RV_RESULT": {"type": () => {return new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"});}, "is_optional": " "}, "IO_READER": {"type": () => {return new abap.types.ABAPObject({qualifiedName: "IF_SXML_READER", RTTIName: "\\INTERFACE=IF_SXML_READER"});}, "is_optional": " "}}},
  "SERIALIZE_REC_ARRAY": {"visibility": "I", "parameters": {"IO_READER": {"type": () => {return new abap.types.ABAPObject({qualifiedName: "IF_SXML_READER", RTTIName: "\\INTERFACE=IF_SXML_READER"});}, "is_optional": " "}, "IT_PATH": {"type": () => {return abap.types.TableFactory.construct(new abap.types.String({qualifiedName: "STRING"}), {"withHeader":false,"keyType":"DEFAULT","primaryKey":{"isUnique":false,"type":"STANDARD","keyFields":[],"name":"primary_key"},"secondary":[]}, "STRING_TABLE");}, "is_optional": " "}, "CT_JSON_PATHS": {"type": () => {return abap.types.TableFactory.construct(new abap.types.String({qualifiedName: "STRING"}), {"withHeader":false,"keyType":"DEFAULT","primaryKey":{"isUnique":false,"type":"STANDARD","keyFields":[],"name":"primary_key"},"secondary":[]}, "STRING_TABLE");}, "is_optional": " "}}},
  "GET_JSON_PATH": {"visibility": "I", "parameters": {"RV_RESULT": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " "}, "IT_PATH": {"type": () => {return abap.types.TableFactory.construct(new abap.types.String({qualifiedName: "STRING"}), {"withHeader":false,"keyType":"DEFAULT","primaryKey":{"isUnique":false,"type":"STANDARD","keyFields":[],"name":"primary_key"},"secondary":[]}, "STRING_TABLE");}, "is_optional": " "}}},
  "GET_PATH_ELEMENTS": {"visibility": "I", "parameters": {"RT_RESULT": {"type": () => {return abap.types.TableFactory.construct(new abap.types.String({qualifiedName: "STRING"}), {"withHeader":false,"keyType":"DEFAULT","primaryKey":{"isUnique":false,"type":"STANDARD","keyFields":[],"name":"primary_key"},"secondary":[]}, "STRING_TABLE");}, "is_optional": " "}, "IV_PATH": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " "}}},
  "BUILD_JSON": {"visibility": "I", "parameters": {"IT_PATH_ELEMENTS": {"type": () => {return abap.types.TableFactory.construct(new abap.types.String({qualifiedName: "STRING"}), {"withHeader":false,"keyType":"DEFAULT","primaryKey":{"isUnique":false,"type":"STANDARD","keyFields":[],"name":"primary_key"},"secondary":[]}, "STRING_TABLE");}, "is_optional": " "}, "IV_VALUE": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " "}, "CV_JSON_STRING": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " "}}},
  "PATH_CONTAINS_ARRAY": {"visibility": "I", "parameters": {"RV_RESULT": {"type": () => {return new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"});}, "is_optional": " "}, "IV_PATH": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " "}}},
  "TO_JSON": {"visibility": "I", "parameters": {"RO_RESULT": {"type": () => {return new abap.types.ABAPObject({qualifiedName: "ZCL_ABAPGIT_AJSON", RTTIName: "\\CLASS=ZCL_ABAPGIT_AJSON"});}, "is_optional": " "}, "IV_JSON_PATH": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " "}}},
  "IS_PRIMITIV": {"visibility": "I", "parameters": {"RV_RESULT": {"type": () => {return new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"});}, "is_optional": " "}, "IV_STRING": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " "}}},
  "IS_COMMENT_OR_EMPTY_LINE": {"visibility": "I", "parameters": {"RV_RESULT": {"type": () => {return new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"});}, "is_optional": " "}, "IV_LINE": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " "}}},
  "SERIALIZE_REC": {"visibility": "U", "parameters": {"IO_READER": {"type": () => {return new abap.types.ABAPObject({qualifiedName: "IF_SXML_READER", RTTIName: "\\INTERFACE=IF_SXML_READER"});}, "is_optional": " "}, "IT_PATH": {"type": () => {return abap.types.TableFactory.construct(new abap.types.String({qualifiedName: "STRING"}), {"withHeader":false,"keyType":"DEFAULT","primaryKey":{"isUnique":false,"type":"STANDARD","keyFields":[],"name":"primary_key"},"secondary":[]}, "STRING_TABLE");}, "is_optional": " "}, "CT_JSON_PATHS": {"type": () => {return abap.types.TableFactory.construct(new abap.types.String({qualifiedName: "STRING"}), {"withHeader":false,"keyType":"DEFAULT","primaryKey":{"isUnique":false,"type":"STANDARD","keyFields":[],"name":"primary_key"},"secondary":[]}, "STRING_TABLE");}, "is_optional": " "}}},
  "DESERIALIZE": {"visibility": "U", "parameters": {"RV_RESULT": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " "}, "IT_JSON_PATH": {"type": () => {return abap.types.TableFactory.construct(new abap.types.String({qualifiedName: "STRING"}), {"withHeader":false,"keyType":"DEFAULT","primaryKey":{"isUnique":false,"type":"STANDARD","keyFields":[],"name":"primary_key"},"secondary":[]}, "STRING_TABLE");}, "is_optional": " "}}}};
  constructor() {
    this.me = new abap.types.ABAPObject();
    this.me.set(this);
    this.INTERNAL_ID = abap.internalIdCounter++;
    this.FRIENDS_ACCESS_INSTANCE = {
      "is_array": this.#is_array.bind(this),
      "is_string_open": this.#is_string_open.bind(this),
      "is_object": this.#is_object.bind(this),
      "serialize_rec_array": this.#serialize_rec_array.bind(this),
      "get_json_path": this.#get_json_path.bind(this),
      "serialize_rec": this.serialize_rec.bind(this),
    };
  }
  async constructor_(INPUT) {
    if (super.constructor_) { await super.constructor_(INPUT); }
    return this;
  }
  async to_json(INPUT) {
    return lcl_json_path.to_json(INPUT);
  }
  static async to_json(INPUT) {
    let ro_result = new abap.types.ABAPObject({qualifiedName: "ZCL_ABAPGIT_AJSON", RTTIName: "\\CLASS=ZCL_ABAPGIT_AJSON"});
    let iv_json_path = INPUT?.iv_json_path;
    if (iv_json_path?.getQualifiedName === undefined || iv_json_path.getQualifiedName() !== "STRING") { iv_json_path = undefined; }
    if (iv_json_path === undefined) { iv_json_path = new abap.types.String({qualifiedName: "STRING"}).set(INPUT.iv_json_path); }
    let lv_path = new abap.types.String({qualifiedName: "STRING"});
    let lv_value = new abap.types.String({qualifiedName: "STRING"});
    let lt_path_elements = abap.types.TableFactory.construct(new abap.types.String({qualifiedName: "STRING"}), {"withHeader":false,"keyType":"DEFAULT","primaryKey":{"isUnique":false,"type":"STANDARD","keyFields":[],"name":"primary_key"},"secondary":[]}, "STRING_TABLE");
    let lv_json = new abap.types.String({qualifiedName: "STRING"});
    abap.statements.find(iv_json_path, {regex: new abap.types.String().set(`(.*)=(.*$)`), submatches: [lv_path,lv_value]});
    if (abap.compare.eq((await this.path_contains_array({iv_path: lv_path})), abap.builtin.abap_true)) {
      lt_path_elements.set((await this.get_path_elements({iv_path: lv_path})));
      await this.build_json({it_path_elements: lt_path_elements, iv_value: lv_value, cv_json_string: lv_json});
      ro_result.set((await abap.Classes['ZCL_ABAPGIT_AJSON'].parse({iv_json: lv_json})));
    } else {
      abap.statements.replace({target: lv_path, all: false, with: abap.CharacterFactory.get(1, ''), of: abap.CharacterFactory.get(2, '$.')});
      abap.statements.replace({target: lv_path, all: false, with: abap.CharacterFactory.get(1, '/'), of: abap.CharacterFactory.get(1, '.')});
      ro_result.set((await abap.Classes['ZCL_ABAPGIT_AJSON'].create_empty({iv_keep_item_order: abap.builtin.abap_true})));
      await ro_result.get().zif_abapgit_ajson$set({iv_path: lv_path, iv_val: lv_value});
    }
    return ro_result;
  }
  async path_contains_array(INPUT) {
    return lcl_json_path.path_contains_array(INPUT);
  }
  static async path_contains_array(INPUT) {
    let rv_result = new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"});
    let iv_path = INPUT?.iv_path;
    if (iv_path?.getQualifiedName === undefined || iv_path.getQualifiedName() !== "STRING") { iv_path = undefined; }
    if (iv_path === undefined) { iv_path = new abap.types.String({qualifiedName: "STRING"}).set(INPUT.iv_path); }
    let lv_array_pattern = new abap.types.String({qualifiedName: "STRING"});
    lv_array_pattern.set(`.*\\[.*\\].*`);
    rv_result.set(abap.builtin.boolc(abap.compare.eq(abap.builtin.matches({val: iv_path, regex: lv_array_pattern}), abap.builtin.abap_true)));
    return rv_result;
  }
  async build_json(INPUT) {
    return lcl_json_path.build_json(INPUT);
  }
  static async build_json(INPUT) {
    let it_path_elements = INPUT?.it_path_elements;
    if (it_path_elements?.getQualifiedName === undefined || it_path_elements.getQualifiedName() !== "STRING_TABLE") { it_path_elements = undefined; }
    if (it_path_elements === undefined) { it_path_elements = abap.types.TableFactory.construct(new abap.types.String({qualifiedName: "STRING"}), {"withHeader":false,"keyType":"DEFAULT","primaryKey":{"isUnique":false,"type":"STANDARD","keyFields":[],"name":"primary_key"},"secondary":[]}, "STRING_TABLE").set(INPUT.it_path_elements); }
    let iv_value = INPUT?.iv_value;
    if (iv_value?.getQualifiedName === undefined || iv_value.getQualifiedName() !== "STRING") { iv_value = undefined; }
    if (iv_value === undefined) { iv_value = new abap.types.String({qualifiedName: "STRING"}).set(INPUT.iv_value); }
    let cv_json_string = new abap.types.String({qualifiedName: "STRING"});
    if (INPUT && INPUT.cv_json_string) {cv_json_string = INPUT.cv_json_string;}
    let lt_new_path_element = abap.types.TableFactory.construct(new abap.types.String({qualifiedName: "STRING"}), {"withHeader":false,"keyType":"DEFAULT","primaryKey":{"isUnique":false,"type":"STANDARD","keyFields":[],"name":"primary_key"},"secondary":[]}, "STRING_TABLE");
    let lv_sub_match = new abap.types.String({qualifiedName: "STRING"});
    let lv_key_name = new abap.types.String({qualifiedName: "STRING"});
    let lv_key_value = new abap.types.String({qualifiedName: "STRING"});
    let lv_name = new abap.types.String({qualifiedName: "STRING"});
    let lv_first_elem = new abap.types.String({qualifiedName: "STRING"});
    lt_new_path_element.set(it_path_elements);
    if (abap.compare.eq(abap.builtin.lines({val: lt_new_path_element}), abap.IntegerFactory.get(0))) {
      return;
    }
    abap.statements.readTable(lt_new_path_element,{index: abap.IntegerFactory.get(1),
      into: lv_first_elem});
    if (abap.compare.eq(lv_first_elem, new abap.types.String().set(`$`))) {
      await abap.statements.deleteInternal(lt_new_path_element,{index: abap.IntegerFactory.get(1)});
      await this.build_json({it_path_elements: lt_new_path_element, iv_value: iv_value, cv_json_string: cv_json_string});
    } else if (abap.compare.eq((await this.is_primitiv({iv_string: lv_first_elem})), abap.builtin.abap_true)) {
      cv_json_string.set(abap.operators.concat(cv_json_string,new abap.types.String().set(` \{"${abap.templateFormatting(lv_first_elem.getOffset({offset: 1}))}": `)));
      await abap.statements.deleteInternal(lt_new_path_element,{index: abap.IntegerFactory.get(1)});
      await this.build_json({it_path_elements: lt_new_path_element, iv_value: iv_value, cv_json_string: cv_json_string});
      cv_json_string.set(abap.operators.concat(cv_json_string,new abap.types.String().set(` }`)));
    } else {
      abap.statements.find(lv_first_elem, {regex: new abap.types.String().set(`\\[(.*)\\]`), submatches: [lv_sub_match]});
      abap.statements.find(lv_sub_match, {regex: new abap.types.String().set(`(\\w+)(?==='([^']*)')`), submatches: [lv_key_name,lv_key_value]});
      abap.statements.readTable(lt_new_path_element,{index: abap.IntegerFactory.get(2),
        into: lv_name});
      await abap.statements.deleteInternal(lt_new_path_element,{index: abap.IntegerFactory.get(1)});
      await abap.statements.deleteInternal(lt_new_path_element,{index: abap.IntegerFactory.get(1)});
      if (abap.compare.eq(abap.builtin.lines({val: lt_new_path_element}), abap.IntegerFactory.get(0))) {
        cv_json_string.set(abap.operators.concat(cv_json_string,new abap.types.String().set(`[ \{ "${abap.templateFormatting(lv_key_name)}": "${abap.templateFormatting(lv_key_value)}", "${abap.templateFormatting(lv_name.getOffset({offset: 1}))}": "${abap.templateFormatting(iv_value)}"\} ]`)));
      } else {
        cv_json_string.set(abap.operators.concat(cv_json_string,new abap.types.String().set(`[ \{ "${abap.templateFormatting(lv_key_name)}": "${abap.templateFormatting(lv_key_value)}", "${abap.templateFormatting(lv_name.getOffset({offset: 1}))}":`)));
        await this.build_json({it_path_elements: lt_new_path_element, iv_value: iv_value, cv_json_string: cv_json_string});
        cv_json_string.set(abap.operators.concat(cv_json_string,new abap.types.String().set(`} ] `)));
      }
    }
  }
  async is_primitiv(INPUT) {
    return lcl_json_path.is_primitiv(INPUT);
  }
  static async is_primitiv(INPUT) {
    let rv_result = new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"});
    let iv_string = INPUT?.iv_string;
    if (iv_string?.getQualifiedName === undefined || iv_string.getQualifiedName() !== "STRING") { iv_string = undefined; }
    if (iv_string === undefined) { iv_string = new abap.types.String({qualifiedName: "STRING"}).set(INPUT.iv_string); }
    abap.statements.find(iv_string, {regex: new abap.types.String().set(`^.\\w+`)});
    rv_result.set(abap.builtin.boolc(abap.compare.eq(abap.builtin.sy.get().subrc, abap.IntegerFactory.get(0))));
    return rv_result;
  }
  async get_path_elements(INPUT) {
    return lcl_json_path.get_path_elements(INPUT);
  }
  static async get_path_elements(INPUT) {
    let rt_result = abap.types.TableFactory.construct(new abap.types.String({qualifiedName: "STRING"}), {"withHeader":false,"keyType":"DEFAULT","primaryKey":{"isUnique":false,"type":"STANDARD","keyFields":[],"name":"primary_key"},"secondary":[]}, "STRING_TABLE");
    let iv_path = INPUT?.iv_path;
    if (iv_path?.getQualifiedName === undefined || iv_path.getQualifiedName() !== "STRING") { iv_path = undefined; }
    if (iv_path === undefined) { iv_path = new abap.types.String({qualifiedName: "STRING"}).set(INPUT.iv_path); }
    let lv_pcre_pattern = new abap.types.String({qualifiedName: "STRING"});
    let lt_match_result = abap.types.TableFactory.construct(new abap.types.Structure({
    "line": new abap.types.Integer({qualifiedName: "I"}),
    "offset": new abap.types.Integer({qualifiedName: "I"}),
    "length": new abap.types.Integer({qualifiedName: "I"}),
    "submatches": abap.types.TableFactory.construct(new abap.types.Structure({
    "offset": new abap.types.Integer({qualifiedName: "I"}),
    "length": new abap.types.Integer({qualifiedName: "I"})}, "SUBMATCH_RESULT", "SUBMATCH_RESULT", {}, {}), {"withHeader":false,"keyType":"DEFAULT","primaryKey":{"isUnique":false,"type":"STANDARD","keyFields":[],"name":"primary_key"},"secondary":[]}, "SUBMATCH_RESULT_TAB")}, "MATCH_RESULT", "MATCH_RESULT", {}, {}), {"withHeader":false,"keyType":"DEFAULT","primaryKey":{"isUnique":false,"type":"STANDARD","keyFields":[],"name":"primary_key"},"secondary":[]}, "MATCH_RESULT_TAB");
    let lv_match = new abap.types.Structure({
    "line": new abap.types.Integer({qualifiedName: "I"}),
    "offset": new abap.types.Integer({qualifiedName: "I"}),
    "length": new abap.types.Integer({qualifiedName: "I"}),
    "submatches": abap.types.TableFactory.construct(new abap.types.Structure({
    "offset": new abap.types.Integer({qualifiedName: "I"}),
    "length": new abap.types.Integer({qualifiedName: "I"})}, "SUBMATCH_RESULT", "SUBMATCH_RESULT", {}, {}), {"withHeader":false,"keyType":"DEFAULT","primaryKey":{"isUnique":false,"type":"STANDARD","keyFields":[],"name":"primary_key"},"secondary":[]}, "SUBMATCH_RESULT_TAB")}, "MATCH_RESULT", "MATCH_RESULT", {}, {});
    let lv_hit = new abap.types.String({qualifiedName: "STRING"});
    let lx_find = new abap.types.ABAPObject({qualifiedName: "CX_ROOT", RTTIName: "\\CLASS=CX_ROOT"});
    lv_pcre_pattern.set(new abap.types.String().set(`(^\\$)|(\\.\\w+)|(\\[[^\\]]*\\])`));
    try {
      abap.statements.find(iv_path, {regex: lv_pcre_pattern, first: false, results: lt_match_result});
    } catch (e) {
      if ((abap.Classes['CX_SY_FIND_INFINITE_LOOP'] && e instanceof abap.Classes['CX_SY_FIND_INFINITE_LOOP']) || (abap.Classes['CX_SY_RANGE_OUT_OF_BOUNDS'] && e instanceof abap.Classes['CX_SY_RANGE_OUT_OF_BOUNDS']) || (abap.Classes['CX_SY_INVALID_REGEX'] && e instanceof abap.Classes['CX_SY_INVALID_REGEX']) || (abap.Classes['CX_SY_REGEX_TOO_COMPLEX'] && e instanceof abap.Classes['CX_SY_REGEX_TOO_COMPLEX'])) {
        lx_find.set(e);
        await abap.Classes['ZCX_ABAPGIT_EXCEPTION'].raise_with_text({ix_previous: lx_find});
      } else {
        throw e;
      }
    }
    for await (const unique310 of abap.statements.loop(lt_match_result)) {
      lv_match.set(unique310);
      lv_hit.set(abap.builtin.substring({val: iv_path, off: lv_match.get().offset, len: lv_match.get().length}));
      abap.statements.append({source: lv_hit, target: rt_result});
    }
    return rt_result;
  }
  async #is_array(INPUT) {
    let rv_result = new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"});
    let io_reader = INPUT?.io_reader;
    if (io_reader?.getQualifiedName === undefined || io_reader.getQualifiedName() !== "IF_SXML_READER") { io_reader = undefined; }
    if (io_reader === undefined) { io_reader = new abap.types.ABAPObject({qualifiedName: "IF_SXML_READER", RTTIName: "\\INTERFACE=IF_SXML_READER"}).set(INPUT.io_reader); }
    rv_result.set(abap.builtin.boolc(abap.compare.eq(io_reader.get().if_sxml_reader$name, abap.CharacterFactory.get(5, 'array'))));
    return rv_result;
  }
  async #is_string_open(INPUT) {
    let rv_result = new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"});
    let io_reader = INPUT?.io_reader;
    if (io_reader?.getQualifiedName === undefined || io_reader.getQualifiedName() !== "IF_SXML_READER") { io_reader = undefined; }
    if (io_reader === undefined) { io_reader = new abap.types.ABAPObject({qualifiedName: "IF_SXML_READER", RTTIName: "\\INTERFACE=IF_SXML_READER"}).set(INPUT.io_reader); }
    rv_result.set(abap.builtin.boolc(abap.compare.eq(io_reader.get().if_sxml_reader$name, abap.CharacterFactory.get(3, 'str')) && abap.compare.eq(io_reader.get().if_sxml_reader$node_type, abap.Classes['IF_SXML_NODE'].if_sxml_node$co_nt_element_open)));
    return rv_result;
  }
  async #is_object(INPUT) {
    let rv_result = new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"});
    let io_reader = INPUT?.io_reader;
    if (io_reader?.getQualifiedName === undefined || io_reader.getQualifiedName() !== "IF_SXML_READER") { io_reader = undefined; }
    if (io_reader === undefined) { io_reader = new abap.types.ABAPObject({qualifiedName: "IF_SXML_READER", RTTIName: "\\INTERFACE=IF_SXML_READER"}).set(INPUT.io_reader); }
    rv_result.set(abap.builtin.boolc(abap.compare.eq(io_reader.get().if_sxml_reader$name, abap.CharacterFactory.get(6, 'object'))));
    return rv_result;
  }
  async serialize_rec(INPUT) {
    let io_reader = INPUT?.io_reader;
    if (io_reader?.getQualifiedName === undefined || io_reader.getQualifiedName() !== "IF_SXML_READER") { io_reader = undefined; }
    if (io_reader === undefined) { io_reader = new abap.types.ABAPObject({qualifiedName: "IF_SXML_READER", RTTIName: "\\INTERFACE=IF_SXML_READER"}).set(INPUT.io_reader); }
    let it_path = INPUT?.it_path;
    if (it_path?.getQualifiedName === undefined || it_path.getQualifiedName() !== "STRING_TABLE") { it_path = undefined; }
    if (it_path === undefined) { it_path = abap.types.TableFactory.construct(new abap.types.String({qualifiedName: "STRING"}), {"withHeader":false,"keyType":"DEFAULT","primaryKey":{"isUnique":false,"type":"STANDARD","keyFields":[],"name":"primary_key"},"secondary":[]}, "STRING_TABLE").set(INPUT.it_path); }
    let ct_json_paths = abap.types.TableFactory.construct(new abap.types.String({qualifiedName: "STRING"}), {"withHeader":false,"keyType":"DEFAULT","primaryKey":{"isUnique":false,"type":"STANDARD","keyFields":[],"name":"primary_key"},"secondary":[]}, "STRING_TABLE");
    if (INPUT && INPUT.ct_json_paths) {ct_json_paths = INPUT.ct_json_paths;}
    let lt_new_path = abap.types.TableFactory.construct(new abap.types.String({qualifiedName: "STRING"}), {"withHeader":false,"keyType":"DEFAULT","primaryKey":{"isUnique":false,"type":"STANDARD","keyFields":[],"name":"primary_key"},"secondary":[]}, "STRING_TABLE");
    let lv_key = new abap.types.String({qualifiedName: "STRING"});
    lt_new_path.set(it_path);
    if (abap.compare.initial((await io_reader.get().if_sxml_reader$read_next_node()))) {
      return;
    }
    if (abap.compare.eq((await this.#is_string_open({io_reader: io_reader})), abap.builtin.abap_true)) {
      abap.statements.append({source: io_reader.get().if_sxml_reader$value, target: lt_new_path});
      lv_key.set((await this.#get_json_path({it_path: lt_new_path})));
      await io_reader.get().if_sxml_reader$read_next_node();
      lv_key.set(new abap.types.String().set(`${abap.templateFormatting(lv_key)}=${abap.templateFormatting(io_reader.get().if_sxml_reader$value)}`));
      abap.statements.append({source: lv_key, target: ct_json_paths});
      await io_reader.get().if_sxml_reader$read_next_node();
      await abap.statements.deleteInternal(lt_new_path,{index: abap.builtin.lines({val: lt_new_path})});
      await this.serialize_rec({io_reader: io_reader, it_path: lt_new_path, ct_json_paths: ct_json_paths});
    } else if (abap.compare.eq((await this.#is_object({io_reader: io_reader})), abap.builtin.abap_true) && abap.compare.eq(io_reader.get().if_sxml_reader$node_type, abap.Classes['IF_SXML_NODE'].if_sxml_node$co_nt_element_open)) {
      abap.statements.append({source: io_reader.get().if_sxml_reader$value, target: lt_new_path});
      await this.serialize_rec({io_reader: io_reader, it_path: lt_new_path, ct_json_paths: ct_json_paths});
    } else if (abap.compare.eq((await this.#is_array({io_reader: io_reader})), abap.builtin.abap_true) && abap.compare.eq(io_reader.get().if_sxml_reader$node_type, abap.Classes['IF_SXML_NODE'].if_sxml_node$co_nt_element_open)) {
      abap.statements.append({source: io_reader.get().if_sxml_reader$value, target: lt_new_path});
      await this.#serialize_rec_array({io_reader: io_reader, it_path: lt_new_path, ct_json_paths: ct_json_paths});
    } else if ((abap.compare.eq((await this.#is_object({io_reader: io_reader})), abap.builtin.abap_true) || abap.compare.eq((await this.#is_array({io_reader: io_reader})), abap.builtin.abap_true)) && abap.compare.eq(io_reader.get().if_sxml_reader$node_type, abap.Classes['IF_SXML_NODE'].if_sxml_node$co_nt_element_close)) {
      await abap.statements.deleteInternal(lt_new_path,{index: abap.builtin.lines({val: lt_new_path})});
      await this.serialize_rec({io_reader: io_reader, it_path: lt_new_path, ct_json_paths: ct_json_paths});
    }
  }
  async #serialize_rec_array(INPUT) {
    let io_reader = INPUT?.io_reader;
    if (io_reader?.getQualifiedName === undefined || io_reader.getQualifiedName() !== "IF_SXML_READER") { io_reader = undefined; }
    if (io_reader === undefined) { io_reader = new abap.types.ABAPObject({qualifiedName: "IF_SXML_READER", RTTIName: "\\INTERFACE=IF_SXML_READER"}).set(INPUT.io_reader); }
    let it_path = INPUT?.it_path;
    if (it_path?.getQualifiedName === undefined || it_path.getQualifiedName() !== "STRING_TABLE") { it_path = undefined; }
    if (it_path === undefined) { it_path = abap.types.TableFactory.construct(new abap.types.String({qualifiedName: "STRING"}), {"withHeader":false,"keyType":"DEFAULT","primaryKey":{"isUnique":false,"type":"STANDARD","keyFields":[],"name":"primary_key"},"secondary":[]}, "STRING_TABLE").set(INPUT.it_path); }
    let ct_json_paths = abap.types.TableFactory.construct(new abap.types.String({qualifiedName: "STRING"}), {"withHeader":false,"keyType":"DEFAULT","primaryKey":{"isUnique":false,"type":"STANDARD","keyFields":[],"name":"primary_key"},"secondary":[]}, "STRING_TABLE");
    if (INPUT && INPUT.ct_json_paths) {ct_json_paths = INPUT.ct_json_paths;}
    let lt_new_path = abap.types.TableFactory.construct(new abap.types.String({qualifiedName: "STRING"}), {"withHeader":false,"keyType":"DEFAULT","primaryKey":{"isUnique":false,"type":"STANDARD","keyFields":[],"name":"primary_key"},"secondary":[]}, "STRING_TABLE");
    let lv_json_path = new abap.types.String({qualifiedName: "STRING"});
    let lv_array_key = new abap.types.String({qualifiedName: "STRING"});
    lt_new_path.set(it_path);
    if (abap.compare.initial((await io_reader.get().if_sxml_reader$read_next_node()))) {
      return;
    }
    if (abap.compare.eq((await this.#is_string_open({io_reader: io_reader})), abap.builtin.abap_true)) {
      abap.statements.append({source: io_reader.get().if_sxml_reader$value, target: lt_new_path});
      lv_json_path.set((await this.#get_json_path({it_path: lt_new_path})));
      await io_reader.get().if_sxml_reader$read_next_node();
      lv_json_path.set(new abap.types.String().set(`${abap.templateFormatting(lv_json_path)}=${abap.templateFormatting(io_reader.get().if_sxml_reader$value)}`));
      abap.statements.append({source: lv_json_path, target: ct_json_paths});
      await io_reader.get().if_sxml_reader$read_next_node();
      await this.serialize_rec({io_reader: io_reader, it_path: lt_new_path, ct_json_paths: ct_json_paths});
    } else if (abap.compare.eq((await this.#is_object({io_reader: io_reader})), abap.builtin.abap_true) && abap.compare.eq(io_reader.get().if_sxml_reader$node_type, abap.Classes['IF_SXML_NODE'].if_sxml_node$co_nt_element_open)) {
      await io_reader.get().if_sxml_reader$read_next_node();
      lv_array_key.set(io_reader.get().if_sxml_reader$value);
      await io_reader.get().if_sxml_reader$read_next_node();
      lv_array_key.set(new abap.types.String().set(`[?(@.${abap.templateFormatting(lv_array_key)}=='${abap.templateFormatting(io_reader.get().if_sxml_reader$value)}')]`));
      abap.statements.append({source: lv_array_key, target: lt_new_path});
      await io_reader.get().if_sxml_reader$read_next_node();
      await io_reader.get().if_sxml_reader$read_next_node();
      abap.statements.append({source: io_reader.get().if_sxml_reader$value, target: lt_new_path});
      lv_json_path.set((await this.#get_json_path({it_path: lt_new_path})));
      await io_reader.get().if_sxml_reader$read_next_node();
      lv_json_path.set(new abap.types.String().set(`${abap.templateFormatting(lv_json_path)}=${abap.templateFormatting(io_reader.get().if_sxml_reader$value)}`));
      abap.statements.append({source: lv_json_path, target: ct_json_paths});
      await io_reader.get().if_sxml_reader$read_next_node();
      await abap.statements.deleteInternal(lt_new_path,{index: abap.builtin.lines({val: lt_new_path})});
      await this.#serialize_rec_array({io_reader: io_reader, it_path: lt_new_path, ct_json_paths: ct_json_paths});
    } else if (abap.compare.eq((await this.#is_array({io_reader: io_reader})), abap.builtin.abap_true) && abap.compare.eq(io_reader.get().if_sxml_reader$node_type, abap.Classes['IF_SXML_NODE'].if_sxml_node$co_nt_element_open)) {
      abap.statements.append({source: io_reader.get().if_sxml_reader$value, target: lt_new_path});
      await this.#serialize_rec_array({io_reader: io_reader, it_path: lt_new_path, ct_json_paths: ct_json_paths});
    } else if ((abap.compare.eq((await this.#is_object({io_reader: io_reader})), abap.builtin.abap_true) || abap.compare.eq((await this.#is_array({io_reader: io_reader})), abap.builtin.abap_true)) && abap.compare.eq(io_reader.get().if_sxml_reader$node_type, abap.Classes['IF_SXML_NODE'].if_sxml_node$co_nt_element_close)) {
      await abap.statements.deleteInternal(lt_new_path,{index: abap.builtin.lines({val: lt_new_path})});
      await this.#serialize_rec_array({io_reader: io_reader, it_path: lt_new_path, ct_json_paths: ct_json_paths});
    }
  }
  async #get_json_path(INPUT) {
    let rv_result = new abap.types.String({qualifiedName: "STRING"});
    let it_path = INPUT?.it_path;
    if (it_path?.getQualifiedName === undefined || it_path.getQualifiedName() !== "STRING_TABLE") { it_path = undefined; }
    if (it_path === undefined) { it_path = abap.types.TableFactory.construct(new abap.types.String({qualifiedName: "STRING"}), {"withHeader":false,"keyType":"DEFAULT","primaryKey":{"isUnique":false,"type":"STANDARD","keyFields":[],"name":"primary_key"},"secondary":[]}, "STRING_TABLE").set(INPUT.it_path); }
    rv_result.set(abap.builtin.concat_lines_of({table: it_path, sep: new abap.types.String().set(`.`)}));
    abap.statements.replace({target: rv_result, all: true, with: new abap.types.String().set(`[`), of: new abap.types.String().set(`.[`)});
    return rv_result;
  }
  async deserialize(INPUT) {
    return lcl_json_path.deserialize(INPUT);
  }
  static async deserialize(INPUT) {
    let rv_result = new abap.types.String({qualifiedName: "STRING"});
    let it_json_path = INPUT?.it_json_path;
    if (it_json_path?.getQualifiedName === undefined || it_json_path.getQualifiedName() !== "STRING_TABLE") { it_json_path = undefined; }
    if (it_json_path === undefined) { it_json_path = abap.types.TableFactory.construct(new abap.types.String({qualifiedName: "STRING"}), {"withHeader":false,"keyType":"DEFAULT","primaryKey":{"isUnique":false,"type":"STANDARD","keyFields":[],"name":"primary_key"},"secondary":[]}, "STRING_TABLE").set(INPUT.it_json_path); }
    let lo_merged = new abap.types.ABAPObject({qualifiedName: "ZIF_ABAPGIT_AJSON", RTTIName: "\\INTERFACE=ZIF_ABAPGIT_AJSON"});
    let lv_json_path = new abap.types.String({qualifiedName: "STRING"});
    let lo_deserialization_result = new abap.types.ABAPObject({qualifiedName: "ZIF_ABAPGIT_AJSON", RTTIName: "\\INTERFACE=ZIF_ABAPGIT_AJSON"});
    let lx_ajson = new abap.types.ABAPObject({qualifiedName: "ZCX_ABAPGIT_AJSON_ERROR", RTTIName: "\\CLASS=ZCX_ABAPGIT_AJSON_ERROR"});
    try {
      lo_merged.set((await abap.Classes['ZCL_ABAPGIT_AJSON'].parse({iv_json: new abap.types.String().set(``)})));
    } catch (e) {
      if ((abap.Classes['ZCX_ABAPGIT_AJSON_ERROR'] && e instanceof abap.Classes['ZCX_ABAPGIT_AJSON_ERROR'])) {
        lx_ajson.set(e);
        await abap.Classes['ZCX_ABAPGIT_EXCEPTION'].raise_with_text({ix_previous: lx_ajson});
      } else {
        throw e;
      }
    }
    for await (const unique311 of abap.statements.loop(it_json_path)) {
      lv_json_path.set(unique311);
      if (abap.compare.eq((await this.is_comment_or_empty_line({iv_line: lv_json_path})), abap.builtin.abap_true)) {
        continue;
      }
      try {
        lo_deserialization_result.set((await this.to_json({iv_json_path: lv_json_path})));
      } catch (e) {
        if ((abap.Classes['ZCX_ABAPGIT_AJSON_ERROR'] && e instanceof abap.Classes['ZCX_ABAPGIT_AJSON_ERROR'])) {
          lx_ajson.set(e);
          await abap.Classes['ZCX_ABAPGIT_EXCEPTION'].raise_with_text({ix_previous: lx_ajson});
        } else {
          throw e;
        }
      }
      try {
        lo_merged.set((await (await abap.Classes['ZCL_ABAPGIT_AJSON_UTILITIES'].new()).get().merge({io_json_a: lo_merged, io_json_b: lo_deserialization_result})));
      } catch (e) {
        if ((abap.Classes['ZCX_ABAPGIT_AJSON_ERROR'] && e instanceof abap.Classes['ZCX_ABAPGIT_AJSON_ERROR'])) {
          lx_ajson.set(e);
          await abap.Classes['ZCX_ABAPGIT_EXCEPTION'].raise_with_text({ix_previous: lx_ajson});
        } else {
          throw e;
        }
      }
    }
    try {
      rv_result.set((await lo_merged.get().zif_abapgit_ajson$stringify({iv_indent: abap.IntegerFactory.get(2)})));
    } catch (e) {
      if ((abap.Classes['ZCX_ABAPGIT_AJSON_ERROR'] && e instanceof abap.Classes['ZCX_ABAPGIT_AJSON_ERROR'])) {
        lx_ajson.set(e);
        await abap.Classes['ZCX_ABAPGIT_EXCEPTION'].raise_with_text({ix_previous: lx_ajson});
      } else {
        throw e;
      }
    }
    return rv_result;
  }
  async is_comment_or_empty_line(INPUT) {
    return lcl_json_path.is_comment_or_empty_line(INPUT);
  }
  static async is_comment_or_empty_line(INPUT) {
    let rv_result = new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"});
    let iv_line = INPUT?.iv_line;
    if (iv_line?.getQualifiedName === undefined || iv_line.getQualifiedName() !== "STRING") { iv_line = undefined; }
    if (iv_line === undefined) { iv_line = new abap.types.String({qualifiedName: "STRING"}).set(INPUT.iv_line); }
    if (abap.compare.initial(iv_line)) {
      rv_result.set(abap.builtin.abap_true);
      return rv_result;
    }
    abap.statements.find(iv_line, {regex: new abap.types.String().set(`^!`)});
    if (abap.compare.eq(abap.builtin.sy.get().subrc, abap.IntegerFactory.get(0))) {
      rv_result.set(abap.builtin.abap_true);
      return rv_result;
    }
    abap.statements.find(iv_line, {regex: new abap.types.String().set(`^#`)});
    if (abap.compare.eq(abap.builtin.sy.get().subrc, abap.IntegerFactory.get(0))) {
      rv_result.set(abap.builtin.abap_true);
      return rv_result;
    }
    return rv_result;
  }
}
abap.Classes['CLAS-ZCL_ABAPGIT_JSON_PATH-LCL_JSON_PATH'] = lcl_json_path;
export {lcl_json_path};