Json 返回 [object Object]

问题描述 投票:0回答:0

所以我试图让它检查对象是否为空或未定义,但每当我检查它时,我都会得到

[object] [Object]
。我不完全确定我做错了什么,因为它在设置 json 时有效。此外,如果这对任何人都很重要,这在 Action Script 2 中。

    var currentSavedOutfits = {}; //I want it to be empty for testing purposes.
    var itemJsonData = com.cp.util.JSONParser.parse(currentSavedOutfits);
    for (var i = 1; i <= INTERFACE.MAX_OUTFIT_SLOTS; ++i) {
        var slotMC = _loc1.outfits_mc["slot" + i + "_mc"];
        var slotData = itemJsonData["slot" + i];
        if (slotData !== undefined && slotData !== "" && slotData !== null ) {
            trace("Does something");
       } else {
           trace("Does something else");
     }

这在设置 JSON 时有效

var currentSavedOutfits = '{"slot1": {"name": "Test Outfit", "head": 0, "face": 103, "body": 0, "neck": 171, "hand": 0, "feet": 0, "color": 9}, "slot2": {"name": "The Yeet", "head": 429, "face": 103, "body": 221, "neck": 0, "hand": 0, "feet": 0, "color": 4}, "slot3": {"name": "The Naked", "head": 0, "face": 0, "body": 0, "neck": 0, "hand": 0, "feet": 0, "color": 6}}';
actionscript
© www.soinside.com 2019 - 2024. All rights reserved.