Parses given JSON string to create new Report
 Returns Stacktrace of the report
189405
def stacktrace
      stacktrace = @struct[:stacktrace]
      return nil if stacktrace.null?

      # There's no sr_stacktrace_dup in libsatyr.so.3, we've got to find out
      # the type ourselves.
      dup = case @struct[:type]
      when :core
        Satyr::FFI.sr_core_stacktrace_dup(stacktrace)
      when :python
        Satyr::FFI.sr_python_stacktrace_dup(stacktrace)
      when :kerneloops
        Satyr::FFI.sr_koops_stacktrace_dup(stacktrace)
      when :java
        Satyr::FFI.sr_java_stacktrace_dup(stacktrace)
      when :gdb
        Satyr::FFI.sr_gdb_stacktrace_dup(stacktrace)
      else
        raise SatyrError, "Invalid report type"
      end

      raise SatyrError, "Failed to obtain stacktrace" if dup.null?

      Stacktrace.send(:new, dup)
    end
1034718
function postResults() {
    if (IS_JSON_FORMAT) {
        const reportPath = `${path.join(PLUGIN_CONFIG.cucumberResultsPath, PLUGIN_CONFIG.cucumberReportName)}.json`;
        const pidReportPath = `${path.join(
            PLUGIN_CONFIG.cucumberResultsPath,
            PLUGIN_CONFIG.cucumberReportName
        )}.${PID_INSTANCE_DATA.pid}.json`;

        if ((!PLUGIN_CONFIG.uniqueReportFileName && fs.existsSync(reportPath))
            || (PLUGIN_CONFIG.uniqueReportFileName && fs.existsSync(pidReportPath))
        ) {
            const currentReportPath = PLUGIN_CONFIG.uniqueReportFileName ? pidReportPath : reportPath;
            const currentReport = fs.readJsonSync(currentReportPath);

            currentReport.map((singleReport) => {
                const featureName = singleReport.name.replace(/\s+/g, '_').replace(/\W/g, '').toLowerCase() || 'noName';
                const browserVersion = PID_INSTANCE_DATA.metadata.browser.version === ''
                    ? ''
                    : `.${PID_INSTANCE_DATA.metadata.browser.version}`;
                const plaformName = PID_INSTANCE_DATA.metadata.platform.name === ''
                    ? ''
                    : `.${PID_INSTANCE_DATA.metadata.platform.name}`;
                const plaformVersion = PID_INSTANCE_DATA.metadata.platform.version === ''
                    ? ''
                    : `.${PID_INSTANCE_DATA.metadata.platform.version}`;
                let fileName = `${featureName}.${PID_INSTANCE_DATA.metadata.browser.name}`;

                fileName += browserVersion + plaformName + plaformVersion;
                const filePath = path.join(PLUGIN_CONFIG.jsonOutputPath, `${fileName}_${Date.now()}.json`);

                /**
                 * If needed remove the previous file if it exists to prevent double reports of 1 feature + browser execution
                 */
                if (PLUGIN_CONFIG.removeExistingJsonReportFile) {
                    fs.readdirSync(PLUGIN_CONFIG.jsonOutputPath)
                        .filter((file) => file.match(new RegExp(fileName, 'ig')))
                        .forEach((file) => fs.removeSync(path.resolve(PLUGIN_CONFIG.jsonOutputPath, file)));
                }

                /**
                 * Add the metadata from the running instance to the report
                 */
                singleReport.metadata = PID_INSTANCE_DATA.metadata;

                /**
                 * Save the file
                 */
                fs.writeJsonSync(filePath, JSON.parse(`[${ JSON.stringify(singleReport) }]`), { spaces: 2 });
            });

            /**
             * Remove the original json report file, defined in the `cucumberOpts.format` if needed
             */
            if (PLUGIN_CONFIG.removeOriginalJsonReportFile) {
                fs.removeSync(currentReportPath);
            }

            if ((PLUGIN_CONFIG.customData || PLUGIN_CONFIG.reportName) && !PLUGIN_CONFIG.automaticallyGenerateReport) {
                console.warn(`
===========================================================================
    YOU ADDED A CUSTOM reportName AND OR ADDED A cucsomerData-object
    WITHOUT SETTING 'automaticallyGenerateReport: true'.
    
    !!!THIS WILL NOT RESULT IN SETTING THE CUSTOM DATA IN THE REPORT!!!                
===========================================================================`);
            }

            /**
             * Generate the HTML report if needed
             */
            if (PLUGIN_CONFIG.automaticallyGenerateReport) {
                /**
                 * If the reportPath is still default, then add the default folder to the same folder
                 * where the results are stored
                 */
                if (PLUGIN_CONFIG.reportPath === REPORT_FOLDER) {
                    PLUGIN_CONFIG.reportPath = path.join(PLUGIN_CONFIG.cucumberResultsPath, REPORT_FOLDER);
                }

                const multiCucumberHTLMReporterConfig = {
                    customMetadata: PLUGIN_CONFIG.customMetadata,
                    displayDuration: PLUGIN_CONFIG.displayDuration,
                    durationInMS: PLUGIN_CONFIG.durationInMS,
                    disableLog: PLUGIN_CONFIG.disableLog,
                    jsonDir: PLUGIN_CONFIG.jsonOutputPath,
                    openReportInBrowser: PLUGIN_CONFIG.openReportInBrowser,
                    reportPath: PLUGIN_CONFIG.reportPath,
                    saveCollectedJSON: PLUGIN_CONFIG.saveCollectedJSON
                };

                /**
                 * Add the custom data if needed
                 */
                if (PLUGIN_CONFIG.customData) {
                    multiCucumberHTLMReporterConfig.customData = PLUGIN_CONFIG.customData;
                }

                /**
                 * Add the custom css if needed
                 */
                if (PLUGIN_CONFIG.customStyle !== '') {
                    multiCucumberHTLMReporterConfig.customStyle = PLUGIN_CONFIG.customStyle;
                }

                /**
                 * Add the override css if needed
                 */
                if (PLUGIN_CONFIG.overrideStyle !== '') {
                    multiCucumberHTLMReporterConfig.overrideStyle = PLUGIN_CONFIG.overrideStyle;
                }

                /**
                 * Add the pageFooter if needed
                 */
                if (PLUGIN_CONFIG.pageFooter) {
                    multiCucumberHTLMReporterConfig.pageFooter = PLUGIN_CONFIG.pageFooter;
                }

                /**
                 * Add the pageTitle if needed
                 */
                if (PLUGIN_CONFIG.pageTitle) {
                    multiCucumberHTLMReporterConfig.pageTitle = PLUGIN_CONFIG.pageTitle;
                }

                /**
                 * Add the custom report name if needed
                 */
                if (PLUGIN_CONFIG.reportName) {
                    multiCucumberHTLMReporterConfig.reportName = PLUGIN_CONFIG.reportName;
                }

                multiCucumberHTLMReporter.generate(multiCucumberHTLMReporterConfig);
            }
        } else {
            console.warn(`\n### File: '${reportPath}' or '${pidReportPath}' is not present! ###\n`);
        }
    }
}
840013
def parse_json_structure(string_item):
    
    if not isinstance(string_item, str):
        raise TypeError("Expected str but got {} instead".format(type(string_item).__name__))

    try:
        item = json.loads(string_item)
    except json.JSONDecodeError:
        raise JsonRpcParseError()

    if isinstance(item, dict):
        return JsonRpcRequest.from_dict(item)
    elif isinstance(item, list):
        if len(item) == 0:
            raise JsonRpcInvalidRequestError()

        request_batch = JsonRpcRequestBatch([])
        for d in item:
            try:
                # handles the case of valid batch but with invalid
                # requests.
                if not isinstance(d, dict):
                    raise JsonRpcInvalidRequestError()
                # is dict, all fine
                parsed_entry = JsonRpcRequest.from_dict(d)
            except JsonRpcInvalidRequestError:
                parsed_entry = GenericResponse.INVALID_REQUEST
            request_batch.add_item(parsed_entry)
        return request_batch
201141
private static String stackTraceToString(List<StackTraceElement> stack) {
		return StringPrinter.buildString(printer -> {
			for (StackTraceElement element : stack) {
				printer.print("at ");
				printer.print(element.getClassName());
				printer.print(".");
				printer.print(element.getMethodName());
				printer.print("(");
				printer.print(element.getFileName());
				printer.print(":");
				printer.print(Integer.toString(element.getLineNumber()));
				printer.println(")");
			}
		});
	}
1056298
private Scope peek() throws JSONException {
		if (this.stack.isEmpty()) {
			throw new JSONException("Nesting problem");
		}
		return this.stack.get(this.stack.size() - 1);
	}
61637
public static String stackTraceText(@NotNull Throwable t) {
		StringBuilderWriter stringWriter = new StringBuilderWriter();
		t.printStackTrace(new PrintWriter(stringWriter)); // NOSONAR
		return stringWriter.toString();
	}
48370
private static String extractPemString(JsonObject json, String fieldName, String msgPrefix) throws NetworkConfigurationException {

        String path = null;
        String pemString = null;

        JsonObject jsonField = getJsonValueAsObject(json.get(fieldName));
        if (jsonField != null) {
            path = getJsonValueAsString(jsonField.get("path"));
            pemString = getJsonValueAsString(jsonField.get("pem"));
        }

        if (path != null && pemString != null) {
            throw new NetworkConfigurationException(format("%s should not specify both %s path and pem", msgPrefix, fieldName));
        }

        if (path != null) {
            // Determine full pathname and ensure the file exists
            File pemFile = new File(path);
            String fullPathname = pemFile.getAbsolutePath();
            if (!pemFile.exists()) {
                throw new NetworkConfigurationException(format("%s: %s file %s does not exist", msgPrefix, fieldName, fullPathname));
            }
            try (FileInputStream stream = new FileInputStream(pemFile)) {
                pemString = IOUtils.toString(stream, "UTF-8");
            } catch (IOException ioe) {
                throw new NetworkConfigurationException(format("Failed to read file: %s", fullPathname), ioe);
            }

        }

        return pemString;
    }
1091613
public static Object parseStrict(String s) throws ParseException {
		return new JSONParser(MODE_RFC4627).parse(s, defaultReader.DEFAULT);
	}
1212295
def json(self, json_string=None):
        
        if json_string is not None:
            return self.__init__(loads(json_string))
        dump = self
        if isinstance(self, HAR.log):
            dump = {"log": dump}
        return dumps(dump, default=lambda x: dict(x))
348744
def json_string(self):
        
        def visit_children(node):
            """ Recursively visit the fragments_tree """
            output_fragments = []
            for child in node.children_not_empty:
                fragment = child.value
                text = fragment.text_fragment
                output_fragments.append({
                    "id": text.identifier,
                    "language": text.language,
                    "lines": text.lines,
                    "begin": gf.time_to_ssmmm(fragment.begin),
                    "end": gf.time_to_ssmmm(fragment.end),
                    "children": visit_children(child)
                })
            return output_fragments
        output_fragments = visit_children(self.fragments_tree)
        return gf.safe_unicode(
            json.dumps({"fragments": output_fragments}, indent=1, sort_keys=True)
        )
1192652
def from_json(json_string):
    
    # parse the provided json_message
    try:            
        parsed_msg = json.loads(json_string)            
    except ValueError as ex:            
        # if the provided json_message is not a valid JSON
        return None
    except TypeError as ex:
        # if json_message not string or buffer
        return None
    herald_version = None
    # check if it is a valid Herald JSON message
    if herald.MESSAGE_HEADERS in parsed_msg:
        if herald.MESSAGE_HERALD_VERSION in parsed_msg[herald.MESSAGE_HEADERS]:
            herald_version = parsed_msg[herald.MESSAGE_HEADERS].get(herald.MESSAGE_HERALD_VERSION)                         
    if herald_version is None or herald_version != herald.HERALD_SPECIFICATION_VERSION:
        _logger.error("Herald specification of the received message is not supported!")
        return None   
    # construct new Message object from the provided JSON object    
    msg = herald.beans.MessageReceived(uid=(parsed_msg[herald.MESSAGE_HEADERS].get(herald.MESSAGE_HEADER_UID) or None), 
                          subject=parsed_msg[herald.MESSAGE_SUBJECT], 
                          content=None, 
                          sender_uid=(parsed_msg[herald.MESSAGE_HEADERS].get(herald.MESSAGE_HEADER_SENDER_UID) or None), 
                          reply_to=(parsed_msg[herald.MESSAGE_HEADERS].get(herald.MESSAGE_HEADER_REPLIES_TO) or None), 
                          access=None,
                          timestamp=(parsed_msg[herald.MESSAGE_HEADERS].get(herald.MESSAGE_HEADER_TIMESTAMP) or None) 
                          )                           
    # set content
    try:
        if herald.MESSAGE_CONTENT in parsed_msg:
            parsed_content = parsed_msg[herald.MESSAGE_CONTENT]                              
            if parsed_content is not None:
                if isinstance(parsed_content, str):
                    msg.set_content(parsed_content)
                else:
                    msg.set_content(jabsorb.from_jabsorb(parsed_content))
    except KeyError as ex:
        _logger.error("Error retrieving message content! " + str(ex)) 
    # other headers
    if herald.MESSAGE_HEADERS in parsed_msg:
        for key in parsed_msg[herald.MESSAGE_HEADERS]:
            if key not in msg._headers:
                msg._headers[key] = parsed_msg[herald.MESSAGE_HEADERS][key]         
    # metadata
    if herald.MESSAGE_METADATA in parsed_msg:
        for key in parsed_msg[herald.MESSAGE_METADATA]:
            if key not in msg._metadata:
                msg._metadata[key] = parsed_msg[herald.MESSAGE_METADATA][key] 
                       
    return msg
1033115
function parseArray () {
  if (tokenType === TOKENTYPE.DELIMITER && token === '[') {
    getToken();

    let array = [];

    if (tokenType === TOKENTYPE.DELIMITER && token === ']') {
      // empty array
      getToken();
      return array;
    }

    // add this array to the stack
    const stackIndex = stack.length;
    stack[stackIndex] = array;

    while (true) {
      // parse item
      path[stackIndex] = array.length + '';
      array.push(parseObject());

      // parse item separator
      if (tokenType !== TOKENTYPE.DELIMITER || token !== ',') {
        break;
      }
      getToken();
    }

    if (tokenType !== TOKENTYPE.DELIMITER || token !== ']') {
      throw createSyntaxError('Comma or end of array "]" expected');
    }
    getToken();

    // remove current entry from the stack
    stack.length = stackIndex;
    path.length = stackIndex;

    return array;
  }

  return parseString();
}
865420
private ArrayList<Track> parseTopTracks(String json) {
    ArrayList<Track> tracks = new ArrayList<>();
    try {
      JsonNode jsonNode = this.objectMapper.readTree(json);
      for (JsonNode trackNode : jsonNode.get("tracks")) {
        JsonNode albumNode = trackNode.get("album");
        String albumName = albumNode.get("name").asText();
        String artistName = trackNode.get("artists").get(0).get("name").asText();
        String trackName = trackNode.get("name").asText();

        tracks.add(new Track(trackName, new Album(albumName, new Artist(artistName))));
      }
    } catch (IOException e) {
      throw new RuntimeException("Failed to parse JSON", e);
    }
    return tracks;
  }
737002
public static CrashReport fromJson(String json) throws IllegalArgumentException {
    try {
      return new CrashReport(json);
    } catch (JSONException je) {
      throw new IllegalArgumentException(je.toString());
    }
  }
912004
public static StringBuilder createStackTrace(StringBuilder s, StackTraceElement[] stack) {
		if (stack != null)
			for (StackTraceElement e : stack) {
				s.append("\n\tat ");
				s.append(e.getClassName());
				if (e.getMethodName() != null) {
					s.append('.');
					s.append(e.getMethodName());
				}
				if (e.getFileName() != null) {
					s.append('(');
					s.append(e.getFileName());
					s.append(':');
					s.append(e.getLineNumber());
					s.append(')');
				}
			}
		return s;
	}
346945
def to_report_json(self):
        

        return self.reporter.json(self.n_lines, self.n_assocs, self.skipped)
1328878
public static Object parse(String json, JSONVisitor handler)
            throws ParseException {
        StringReader reader = new StringReader(json);
        try {
            return parse(reader, handler);
        } catch (IOException e) {
            throw new ParseException(e.getMessage(), 0);
        } finally {
            reader.close();
        }
    }