Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HandyJSON!!! #130

Open
shang1219178163 opened this issue Mar 8, 2019 · 6 comments
Open

HandyJSON!!! #130

shang1219178163 opened this issue Mar 8, 2019 · 6 comments

Comments

@shang1219178163
Copy link

https://github.com/alibaba/HandyJSON

@xyhuangjia
Copy link

@shang1219178163 我改了一个,大佬要不要试试?

@RondaHo
Copy link

RondaHo commented Mar 29, 2019

@shang1219178163 我改了一个,大佬要不要试试?

大佬发出来试试

@RondaHo
Copy link

RondaHo commented Mar 29, 2019

need HandyJson support

@shang1219178163
Copy link
Author

@shang1219178163 我改了一个,大佬要不要试试?

大佬发出来试试

func mapping(mapper: HelpingMapper) {
这个方法也实现,不需要的字段大家可以自由删除就好了

还有就是现在大部分项目都是swift oc混编,你需要考虑oc的兼容性,大兄弟

@tangbl93
Copy link

tangbl93 commented Nov 17, 2020

支持HandyJSON和默认值的版本 https://gitee.com/tangbl93/jsonexport 欢迎各位大佬体验。

//
//	CashListItemData.swift
//	Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport

import HandyJSON


class CashListItemData : HandyJSON {

	var hc_id : Int = 0
	var u_nickname : String = ""

	required init() {}

}

@shang1219178163
Copy link
Author

shang1219178163 commented Jan 4, 2021

https://github.com/shang1219178163/JSONExport.git

解析 AppStore的返回的app 详情,生成类如下:

//
//	RootClass.swift
//	Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport

import Foundation 
import HandyJSON


@objcMembers class RootClass: NSObject, HandyJSON{

    var resultCount : Int = 0
    var results : [Result]?


    ///	implement an empty initializer.
    required override init(){
    }

    ///	HandyJSON - Comment out does not need to convert.
    func mapping(mapper: HelpingMapper)	{
	    mapper <<< resultCount <-- "resultCount"
	    mapper <<< results <-- "results"
	    
    }

}

@objcMembers class Result: NSObject, HandyJSON{

    var advisories : [String]?
    var appletvScreenshotUrls : [AnyObject]?
    var artistId : Int = 0
    var artistName : String?
    var artistViewUrl : String?
    var artworkUrl100 : String?
    var artworkUrl512 : String?
    var artworkUrl60 : String?
    var averageUserRatingForCurrentVersion : CGFloat = 0
    var bundleId : String?
    var contentAdvisoryRating : String?
    var currency : String?
    var currentVersionReleaseDate : String?
    var descriptionField : String?
    var features : [AnyObject]?
    var fileSizeBytes : String?
    var formattedPrice : String?
    var genreIds : [String]?
    var genres : [String]?
    var ipadScreenshotUrls : [AnyObject]?
    var isGameCenterEnabled : Bool = false
    var isVppDeviceBasedLicensingEnabled : Bool = false
    var kind : String?
    var languageCodesISO2A : [String]?
    var minimumOsVersion : String?
    var price : CGFloat = 0
    var primaryGenreId : Int = 0
    var primaryGenreName : String?
    var releaseDate : String?
    var releaseNotes : String?
    var screenshotUrls : [String]?
    var sellerName : String?
    var sellerUrl : String?
    var supportedDevices : [String]?
    var trackCensoredName : String?
    var trackContentRating : String?
    var trackId : Int = 0
    var trackName : String?
    var trackViewUrl : String?
    var userRatingCountForCurrentVersion : Int = 0
    var version : String?
    var wrapperType : String?


    ///	implement an empty initializer.
    required override init(){
    }

    ///	HandyJSON - Comment out does not need to convert.
    func mapping(mapper: HelpingMapper)	{
	    mapper <<< advisories <-- "advisories"
	    mapper <<< appletvScreenshotUrls <-- "appletvScreenshotUrls"
	    mapper <<< artistId <-- "artistId"
	    mapper <<< artistName <-- "artistName"
	    mapper <<< artistViewUrl <-- "artistViewUrl"
	    mapper <<< artworkUrl100 <-- "artworkUrl100"
	    mapper <<< artworkUrl512 <-- "artworkUrl512"
	    mapper <<< artworkUrl60 <-- "artworkUrl60"
	    mapper <<< averageUserRatingForCurrentVersion <-- "averageUserRatingForCurrentVersion"
	    mapper <<< bundleId <-- "bundleId"
	    mapper <<< contentAdvisoryRating <-- "contentAdvisoryRating"
	    mapper <<< currency <-- "currency"
	    mapper <<< currentVersionReleaseDate <-- "currentVersionReleaseDate"
	    mapper <<< descriptionField <-- "description"
	    mapper <<< features <-- "features"
	    mapper <<< fileSizeBytes <-- "fileSizeBytes"
	    mapper <<< formattedPrice <-- "formattedPrice"
	    mapper <<< genreIds <-- "genreIds"
	    mapper <<< genres <-- "genres"
	    mapper <<< ipadScreenshotUrls <-- "ipadScreenshotUrls"
	    mapper <<< isGameCenterEnabled <-- "isGameCenterEnabled"
	    mapper <<< isVppDeviceBasedLicensingEnabled <-- "isVppDeviceBasedLicensingEnabled"
	    mapper <<< kind <-- "kind"
	    mapper <<< languageCodesISO2A <-- "languageCodesISO2A"
	    mapper <<< minimumOsVersion <-- "minimumOsVersion"
	    mapper <<< price <-- "price"
	    mapper <<< primaryGenreId <-- "primaryGenreId"
	    mapper <<< primaryGenreName <-- "primaryGenreName"
	    mapper <<< releaseDate <-- "releaseDate"
	    mapper <<< releaseNotes <-- "releaseNotes"
	    mapper <<< screenshotUrls <-- "screenshotUrls"
	    mapper <<< sellerName <-- "sellerName"
	    mapper <<< sellerUrl <-- "sellerUrl"
	    mapper <<< supportedDevices <-- "supportedDevices"
	    mapper <<< trackCensoredName <-- "trackCensoredName"
	    mapper <<< trackContentRating <-- "trackContentRating"
	    mapper <<< trackId <-- "trackId"
	    mapper <<< trackName <-- "trackName"
	    mapper <<< trackViewUrl <-- "trackViewUrl"
	    mapper <<< userRatingCountForCurrentVersion <-- "userRatingCountForCurrentVersion"
	    mapper <<< version <-- "version"
	    mapper <<< wrapperType <-- "wrapperType"
	    
    }

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants