export class JsonAnalization {
  /**
   * Raw string Analization for JSON string.
   * @description Editing with string.util.ts
   */
  public static receiveAnalization(jsonStr: string): any {
    const startJson = jsonStr.indexOf('{');
    const endJson = jsonStr.lastIndexOf('}');

    if (startJson >= 0 && startJson < endJson) {
      jsonStr = jsonStr
        .substring(startJson, endJson + 1)
        .replace(/\n"/gi, '"')
        .replace(/\n}/gi, '}')
        .replace(/\n/gi, '\\n');

      return JSON.parse(jsonStr);
    } else {
      throw new Error('Invalid Json String');
    }
  }
}
