Wireshark 5.1.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
JsoncDocument Class Reference

#include <jsonc_document.h>

Public Member Functions

bool parse (const QByteArray &jsonc)
const QJsonDocument & document () const
const QString & errorString () const
int errorLine () const
int errorColumn () const
int lineOf (const QString &name, const QString &child=QString()) const

Detailed Description

A JSON document read from JSONC text (JSON with line and block comments).

Comments are blanked by json_strip_jsonc_comments(), which keeps the offset of every other byte, so error positions and lines refer to the original text. QJsonDocument carries no positions; lineOf() finds a member by searching the text.

Member Function Documentation

◆ document()

const QJsonDocument & JsoncDocument::document ( ) const
inline

The parsed document; null after a failed parse().

◆ errorColumn()

int JsoncDocument::errorColumn ( ) const
inline

1-based column (in bytes) of the syntax error, or 0 when unknown.

◆ errorLine()

int JsoncDocument::errorLine ( ) const
inline

1-based line of the syntax error, or 0 when unknown.

◆ errorString()

const QString & JsoncDocument::errorString ( ) const
inline

Why the last parse() failed, translated; empty after success.

◆ lineOf()

int JsoncDocument::lineOf ( const QString & name,
const QString & child = QString() ) const

1-based line of the member "name":, or 0 when it is absent. With child, the line of the first "child": after it, which finds a key inside an object in the usual one-member-per-line layout.

◆ parse()

bool JsoncDocument::parse ( const QByteArray & jsonc)

Parses jsonc.

Returns
true when the text is valid JSON once comments are removed.

The documentation for this class was generated from the following files: