当前位置: 首页>>代码示例>>Golang>>正文


Golang JSONMap.GetString方法代码示例

本文整理汇总了Golang中marvin/json/jsondata.JSONMap.GetString方法的典型用法代码示例。如果您正苦于以下问题:Golang JSONMap.GetString方法的具体用法?Golang JSONMap.GetString怎么用?Golang JSONMap.GetString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在marvin/json/jsondata.JSONMap的用法示例。


在下文中一共展示了JSONMap.GetString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: validateGetCoinCountRequest

//
// { "verb": "getCoincount", "name": fb-name }
// { "result": true, "answer" : 6357] }
// { "result": false, "answer" : "not a registered user"] }
//
func validateGetCoinCountRequest(req *jsondata.JSONMap) Request {
	name, r1 := req.GetString("name")

	json := "{\"result\": false, \"answer\": \"missing or invalid arguments in getPendingCoinRequests request\"}"
	if !r1 || len(name) < 6 {
		return &BadRequest{json}
	}
	return datastore.NewGetCoinCount(name)
}
开发者ID:nrchandan,项目名称:marvin-go,代码行数:14,代码来源:request.go

示例2: validateGetAchievements

func validateGetAchievements(req *jsondata.JSONMap) Request {
	hash, r1 := req.GetString("hash")

	json := "{\"result\": false, \"answer\": \"missing or invalid arguments in getAchievements request\"}"
	if !r1 || len(hash) < 6 {
		return &BadRequest{json}
	}
	return datastore.NewGetAchievementRequest(hash)
}
开发者ID:nrchandan,项目名称:marvin-go,代码行数:9,代码来源:request.go

示例3: validateGetLeaderBoard

func validateGetLeaderBoard(req *jsondata.JSONMap) Request {
	hash, r1 := req.GetString("hash")

	if !r1 || len(hash) < 6 {
		jsonRes := "{\"result\": false, \"answer\": \"Missing or Invalid data in getLeaderBoard request\"}"
		return &BadRequest{jsonRes}
	}

	return datastore.NewLeaderBoardRequest(hash)
}
开发者ID:nrchandan,项目名称:marvin-go,代码行数:10,代码来源:request.go

示例4: validateUnregisterRequest

// unregister: (in) json
//    { "name": "[email protected]", "hash":"123456..." }
func validateUnregisterRequest(req *jsondata.JSONMap) Request {
	name, r1 := req.GetString("name")
	hash, r2 := req.GetString("hash")

	s := "{\"result\": false, \"answer\": \"missing or invalid arguments in the request\"}"
	if !r1 || !r2 || len(name) < 6 || len(hash) < 6 {
		return &BadRequest{s}
	}
	return datastore.NewUnregisterRequest(name, hash)
}
开发者ID:nrchandan,项目名称:marvin-go,代码行数:12,代码来源:request.go

示例5: validateSyncCoinCounts

//
// {"verb": "syncCoinCounts", "hash": <user_hash>, "count": <count>}
//
func validateSyncCoinCounts(req *jsondata.JSONMap) Request {
	hash, r1 := req.GetString("hash")
	count, r2 := req.GetUInt("count")

	json := "{\"result\": false, \"answer\": \"missing or invalid arguments in syncCoinCount request\"}"
	if !r1 || !r2 || count <= 0 || len(hash) < 6 {
		return &BadRequest{json}
	}
	return datastore.NewSyncCoinCounts(hash, count)
}
开发者ID:nrchandan,项目名称:marvin-go,代码行数:13,代码来源:request.go

示例6: validateGetPendingCoinRequests

//
// { "verb": "getPendingCoinRequests", "hash": <user-id>, "limit": <unsigned integer> }
// { "result": true, "answer" : [zero-or-more{"name": <name>, "count": <unsigned int>}] }
//
func validateGetPendingCoinRequests(req *jsondata.JSONMap) Request {
	hash, r1 := req.GetString("hash")
	limit, r2 := req.GetUInt("limit")

	json := "{\"result\": false, \"answer\": \"missing or invalid arguments in getPendingCoinRequests request\"}"
	if !r1 || !r2 || limit <= 0 || len(hash) < 6 {
		return &BadRequest{json}
	}
	return datastore.NewGetPendingCoinRequests(hash, limit)
}
开发者ID:nrchandan,项目名称:marvin-go,代码行数:14,代码来源:request.go

示例7: validateSetAchievement

func validateSetAchievement(req *jsondata.JSONMap) Request {
	hash, r1 := req.GetString("hash")
	achievement, r2 := req.GetUInt("achievement")

	json := "{\"result\": false, \"answer\": \"missing or invalid arguments in setAchievement request\"}"
	if !r1 || !r2 || len(hash) < 6 {
		return &BadRequest{json}
	}
	return datastore.NewSetAchievementRequest(hash, achievement)
}
开发者ID:nrchandan,项目名称:marvin-go,代码行数:10,代码来源:request.go

示例8: validateGetScore

//
// { "verb": "getScore", "hash": <user-id> , "game": <game-name>}
// { "result": true, "answer" : <score-unsigned-int> }
// { "result": false, "answer" : "invalid user" }
//
func validateGetScore(req *jsondata.JSONMap) Request {
	hash, r1 := req.GetString("hash")
	game, r2 := req.GetString("game")

	json := "{\"result\": false, \"answer\": \"missing or invalid arguments in getScore request\"}"
	if !r1 || !r2 || len(hash) < 6 || len(game) < 6 {
		return &BadRequest{json}
	}

	return datastore.NewGetScoreRequest(hash, game)
}
开发者ID:nrchandan,项目名称:marvin-go,代码行数:16,代码来源:request.go

示例9: ValidateRequest

func ValidateRequest(req *jsondata.JSONMap) *Response {
	err := MissingVerb

	if cmd, res := req.GetString("verb"); res {
		err = InvalidVerb
		if handler := reqHandlers[cmd]; handler != nil {
			return handler(req)
		}
	}
	panic(err)
}
开发者ID:nrchandan,项目名称:marvin-go,代码行数:11,代码来源:cmd.go

示例10: validateReceiveMessage

func validateReceiveMessage(req *jsondata.JSONMap) Request {
	to, r1 := req.GetString("receiver") // hash of the receiver
	limit, _ := req.GetUInt("limit")    // ignored, at the moment

	// additionally, we need to record the date and time of this response

	if !r1 || len(to) < 6 {
		jsonRes := "{\"result\": false, \"answer\": \"Missing or Invalid data in receiveMessage request\"}"
		return &BadRequest{jsonRes}
	}

	return datastore.NewReceiveMessage(to, limit)
}
开发者ID:nrchandan,项目名称:marvin-go,代码行数:13,代码来源:request.go

示例11: validateRequestCoins

func validateRequestCoins(req *jsondata.JSONMap) Request {
	count, r1 := req.GetUInt("count")
	requester, r2 := req.GetString("requester") // hash
	donor, r3 := req.GetString("donor")         // fb id

	// additionally, we need to record the date and time of this request

	if !r1 || !r2 || !r3 || len(requester) < 6 || len(donor) < 6 || count <= 0 {
		jsonRes := "{\"result\": false, \"answer\": \"Missing or Invalid data in requestCoins request\"}"
		return &BadRequest{jsonRes}
	}
	return datastore.NewCoinsRequest(requester, donor, count)
}
开发者ID:nrchandan,项目名称:marvin-go,代码行数:13,代码来源:request.go

示例12: validateOfferCoins

func validateOfferCoins(req *jsondata.JSONMap) Request {
	offer, r1 := req.GetUInt("offer")
	countOnDevice, r2 := req.GetUInt("countOnDevice")
	requester, r3 := req.GetString("requester") // fb id
	donor, r4 := req.GetString("donor")         // hash

	// additionally, we need to record the date and time of this response

	if !r1 || !r2 || !r3 || !r4 || len(donor) < 6 || len(requester) < 6 || offer <= 0 || countOnDevice <= 0 {
		jsonRes := "{\"result\": false, \"answer\": \"Missing or Invalid data in offerCoins request\"}"
		return &BadRequest{jsonRes}
	}

	return datastore.NewCoinsOffer(requester, donor, offer, countOnDevice)
}
开发者ID:nrchandan,项目名称:marvin-go,代码行数:15,代码来源:request.go

示例13: validateRequest

func validateRequest(httpReq *http.Request, jsonMap *jsondata.JSONMap) Request {
	var reason string = "missing verb in the request"

	if cmd, res := jsonMap.GetString("verb"); res {
		reason = "Invalid or unknown REST-resource and verb combined in the request (" + httpReq.RawURL + " : " + cmd + ")"
		if handler := reqHandlers[cmd]; handler != nil {
			if isVerbValidForResource(httpReq.URL.Path, cmd) {
				return handler(jsonMap)
			}
		}
	}

	msg := "{\"result\": false, \"answer\": \"" + reason + "\"}"
	return &BadRequest{msg}
}
开发者ID:nrchandan,项目名称:marvin-go,代码行数:15,代码来源:request.go

示例14: parseUpdateParams

func parseUpdateParams(req *jsondata.JSONMap) *CheckUpdateRequestParams {
	uid := getUID(req)
	verApp, r1 := req.GetString("verApp")
	verRes, r2 := req.GetString("verRes")
	if !r1 || !r2 {
		return nil
	}

	portraitX := 0
	portraitY := 0
	density := 0
	size := InvalidScreen

	portraitX, _ = req.GetUInt("portraitX")
	portraitY, _ = req.GetUInt("portraitY")
	if portraitX == 0 || portraitY == 0 {
		return nil
	}

	d, _ := req.GetString("density")
	density = screenDensity(d)
	d, _ = req.GetString("screenSize")
	size = screenSize(d)

	p := CheckUpdateRequestParams{uid, verApp, verRes,
		portraitX, portraitY,
		density, size}
	return &p

}
开发者ID:nrchandan,项目名称:marvin-go,代码行数:30,代码来源:cmd.go

示例15: ValidateRegisterRequest

func ValidateRegisterRequest(req *jsondata.JSONMap) *Response {
	name, r1 := req.GetString("name")
	password, r2 := req.GetString("password")
	device, r3 := req.GetString("deviceId")

	if r1 && r2 && r3 {
		osVer, _ := req.GetString("osVersion")
		hasher := sha1.New()
		hasher.Write([]byte(name + password + device))
		fmt.Printf("osVer: %v, hash size: %v, hash sum: %v\n",
			osVer, hasher.Size(), hasher.Sum())
		return nil
	}

	panic("Ill-formed JSON for register request")
}
开发者ID:nrchandan,项目名称:marvin-go,代码行数:16,代码来源:cmd.go


注:本文中的marvin/json/jsondata.JSONMap.GetString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。