Fix JFile to normalize whitespace when loading JSON from disk
JString::operator=(ZString) already stripped whitespace between JSON structural tokens before parsing, but JFile constructed via MFile file- loading bypassed that path entirely, so any pretty-printed/hand-edited JSON file silently failed every locate()/exists()/get*() call. Widen removeWhitespace() to protected and call it from JFile constructor.
This commit is contained in:
1 parent
6b188fbee5
commit
d7057ebb00
5 files changed
+29
-2
No files matched your search
@@ -193,9 +193,22 @@ namespace coreutils {
|
||||
|
||||
virtual void changed(ZString key, ZString value);
|
||||
|
||||
private:
|
||||
protected:
|
||||
|
||||
///
|
||||
/// Strips whitespace between JSON structural tokens (indentation,
|
||||
/// newlines, spaces after ':'/',') - the parser expects compact JSON
|
||||
/// internally. operator=(ZString) already calls this for in-memory
|
||||
/// assignment; JFile's constructor also calls it after loading a
|
||||
/// file's raw bytes, which otherwise bypasses this entirely (see
|
||||
/// JFile.cpp). Protected rather than private specifically so JFile
|
||||
/// can reach it.
|
||||
///
|
||||
|
||||
void removeWhitespace();
|
||||
|
||||
private:
|
||||
|
||||
///
|
||||
/// Structural helpers used internally by locate()/set() to correctly skip
|
||||
/// past a value of any JSON type without being confused by JSON-structural
|
||||
|
||||
Reference in new issue
Block a user