You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Issue :
When using haxe.Json.stringify on a class which inherits a class with at least one method and no variables, pretty formatting will be broken with a missing line return and wrong indentation.
This is a minor issue that can safely be ignored.
Example :
classJsonPrettyClass {
publicstaticfunctionmain() {
varp=newParentClass();
varc=newChildClass();
// If parent class had variables they would be last, thus causing no issue// trace("-- Parent class fields --");// for (f in Type.getInstanceFields(ParentClass)) {// trace(f);// }// Child class field variables are before parent class methods// trace("-- Child class fields --");// for (f in Type.getInstanceFields(ChildClass)) {// trace(f);// }varjson=haxe.Json.stringify(c, "\t");
trace(json);
}
}
classParentClass {
// no field variable, the issue does not reproduce when there is onefunctionanyFunc() {}
publicfunctionnew() {}
}
classChildClassextendsParentClass {
varanyVar:Int;
}
My understanding :
This is caused by the changes in this commit. In the specific case when the object which is passed to write happens to be an instance of a class which inherits a class with only methods and no variables, the if (i == last) condition in fieldsString is skipped.
Thanks! That's a nice edge case which apparently went unnoticed for 10 years. I've applied the fix as you've suggested, and added your example as a test. We will also add this to 4.3.
Haxe version : Tested on 4.3.2
Issue :
When using
haxe.Json.stringify
on a class which inherits a class with at least one method and no variables, pretty formatting will be broken with a missing line return and wrong indentation.This is a minor issue that can safely be ignored.
Example :
My understanding :
This is caused by the changes in this commit. In the specific case when the object which is passed to
write
happens to be an instance of a class which inherits a class with only methods and no variables, theif (i == last)
condition infieldsString
is skipped.Fix proposal :
fix-proposal.patch
The text was updated successfully, but these errors were encountered: