2015-01-20 42 views
1

我有以下的JSON,我需要拉@name如何分析@name許可證的JSON

"@name": "Reuters TV iOS", 
"license": [{ 
    "@name": "Apache License 2.0", 
    "component": [{ 
     "name": "RMStore", 
     "url": "http://github.com/robotmedia/RMStore/" 
    }, { 
     "name": "mixpanel-iphone", 
     "url": "http://github.com/mixpanel/mixpanel-iphone/" 
    }, { 
     "name": "facebook-ios-sdk", 
     "url": "http://github.com/facebook/facebook-ios-sdk/" 
    }], 
    "licensetext": "text " 
}, { 
    "@name": "Apple MIT License", 
    "component": { 
     "name": "Apple iOS Developer Library", 
     "url": "" 
    }, 
    "licensetext": " text" 
}, { 
    "@name": "BSD 3-clause \"New\" or \"Revised\" License", 
    "component": [{ 
     "name": "Reachability-DDG", 
     "url": "" 
    }, { 
     "name": "Tweaks", 
     "url": "http://github.com/facebook/Tweaks/" 
    }, { 
     "name": "NYXImagesKit", 
     "url": "http://github.com/Nyx0uf/NYXImagesKit/" 
    }, { 
     "name": "pop", 
     "url": "http://github.com/facebook/pop/" 
    }, { 
     "name": "JLRoutes", 
     "url": "http://github.com/joeldev/JLRoutes/" 
    }], 
    "licensetext": "text " 
}, { 
    "@name": "Deusty BSD- License", 
    "component": { 
     "name": "CocoaLumberjack", 
     "url": "http://github.com/CocoaLumberjack/CocoaLumberjack/" 
    }, 
    "licensetext": " text" 
}, { 
    "@name": "MIT License", 
    "component": [{ 
     "name": "SDWebImage", 
     "url": "http://github.com/rs/SDWebImage/" 
    }, { 
     "name": "SVProgressHUD", 
     "url": "http://github.com/TransitApp/SVProgressHUD/" 
    }, { 
     "name": "TableViewCellWithAutoLayout", 
     "url": "" 
    }, { 
     "name": "OHHTTPStubs", 
     "url": "http://github.com/AliSoftware/OHHTTPStubs/" 
    }, { 
     "name": "XCTestAsync", 
     "url": "http://github.com/touchableideas/XCTestAsync/" 
    }, { 
     "name": "objection", 
     "url": "http://github.com/atomicobject/objection/" 
    }, { 
     "name": "houston", 
     "url": "http://github.com/nomad/houston/" 
    }, { 
     "name": "YLMoment", 
     "url": "http://github.com/YannickL/YLMoment/" 
    }, { 
     "name": "ReactiveCocoa", 
     "url": "http://github.com/ReactiveCocoa/ReactiveCocoa/" 
    }, { 
     "name": "cocos2d-iphone", 
     "url": "http://github.com/cocos2d/cocos2d-iphone/" 
    }, { 
     "name": "Aspects", 
     "url": "http://github.com/steipete/Aspects/" 
    }, { 
     "name": "TTTAttributedLabel", 
     "url": "http://github.com/mattt/TTTAttributedLabel/" 
    }, { 
     "name": "Mantle", 
     "url": "http://github.com/Mantle/Mantle/" 
    }, { 
     "name": "Masonry", 
     "url": "http://github.com/Masonry/Masonry/" 
    }, { 
     "name": "apple_push_certs", 
     "url": "http://rubygems.org/gems/apple_push_certs" 
    }, { 
     "name": "HockeySDK-iOS", 
     "url": "http://github.com/bitstadium/HockeySDK-iOS/" 
    }], 
    "licensetext": " text " 
}, { 
    "@name": "OpenSSL Combined License", 
    "component": { 
     "name": "OpenSSL", 
     "url": "http://www.openssl.org/" 
    }, 
    "licensetext": "text" 
}, { 
    "@name": "SIL Open Font License 1.1", 
    "component": { 
     "name": "Font-Awesome", 
     "url": "http://github.com/FortAwesome/Font-Awesome/" 
    }, 
    "licensetext": "text" 
}, { 
    "@name": "zlib License", 
    "component": [{ 
     "name": "iCarousel", 
     "url": "http://github.com/nicklockwood/iCarousel/" 
    }, { 
     "name": "FXKeychain", 
     "url": "http://github.com/nicklockwood/FXKeychain/" 
    }, { 
     "name": "FXForms", 
     "url": "http://github.com/nicklockwood/FXForms/" 
    }], 
    "licensetext": "text" 
}], 
"isProjectComplete": "true" 
}; 

我能夠得到nameURLlicense,但不知道怎麼去@name顯示在頂部,例如「Apache許可證2.0」。

這裏的當前狀態:jsfiddle

回答

0

如果我理解正確的,你的問題是你不能使用特殊字符,如@ JS屬性名稱。使用括號:json['@name']