Created
July 11, 2018 11:52
-
-
Save mastef/21288623c018fa2edec692adc6db66bf to your computer and use it in GitHub Desktop.
haxe json circular reference patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var _data:Dynamic = ...; | |
var cache:Array<Dynamic> = []; | |
var jsonString = haxe.Json.stringify(_data, function(key:Dynamic, value:Dynamic) { | |
// kill keys you don't want here | |
// if(key == "ba") return null; | |
// only filter objects | |
if(value != null && Reflect.isObject(value)) { | |
if(cache.indexOf(value) > -1) { | |
return null; | |
} | |
// store value | |
cache.push(value); | |
} | |
return value; | |
}); | |
js.Browser.window.console.log(jsonString); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment