コード例 #1
0
ファイル: json.go プロジェクト: crackcomm/go-core
// Encode - json.encode - encodes all values in context from `encode` list to JSON.
// Example:
// 	{
//		"name": "json.encode",
//		"ctx": {
//			"encode": ["content"],
//			"content": [1, 2, 3]
//		}
//	}
func Encode(ctx action.Map) (action.Map, error) {
	// Pop encode value - context keys to encode
	ctx.Transform(ctx.Pop("encode"), encodeFunc)
	return ctx, nil
}
コード例 #2
0
ファイル: trim.go プロジェクト: crackcomm/go-core
// TrimSpaces - filter.trim - trims all string values in context from `trim` list.
// Example:
// 	{
//		"name": "filter.trim",
//		"ctx": {
//			"trim": ["content", "other"],
//			"content": "   some content to trim out of white space    ",
//			"other": "   some other content to trim out of white space    "
//		}
//	}
func TrimSpaces(ctx action.Map) (action.Map, error) {
	// Pop trim value - context keys to trim
	ctx.Transform(ctx.Pop("trim"), trimFunc)

	return ctx, nil
}
コード例 #3
0
ファイル: json.go プロジェクト: crackcomm/go-core
// Decode - json.decode - decodes all JSON values in context from `decode` list.
// Example:
// 	{
//		"name": "json.decode",
//		"ctx": {
//			"decode": ["content"],
//			"content": "[1, 2, 3]"
//		}
//	}
func Decode(ctx action.Map) (action.Map, error) {
	// Pop decode value - context keys to decode
	ctx.Transform(ctx.Pop("decode"), decodeFunc)

	return ctx, nil
}