@values extracts the values from an object. {"first":"Tom","last":"Smith"} -> ["Tom","Smith"]
(json, arg string)
| 3126 | // |
| 3127 | // {"first":"Tom","last":"Smith"} -> ["Tom","Smith"] |
| 3128 | func modValues(json, arg string) string { |
| 3129 | v := Parse(json) |
| 3130 | if !v.Exists() { |
| 3131 | return "[]" |
| 3132 | } |
| 3133 | if v.IsArray() { |
| 3134 | return json |
| 3135 | } |
| 3136 | var out strings.Builder |
| 3137 | out.WriteByte('[') |
| 3138 | var i int |
| 3139 | v.ForEach(func(_, value Result) bool { |
| 3140 | if i > 0 { |
| 3141 | out.WriteByte(',') |
| 3142 | } |
| 3143 | out.WriteString(value.Raw) |
| 3144 | i++ |
| 3145 | return true |
| 3146 | }) |
| 3147 | out.WriteByte(']') |
| 3148 | return out.String() |
| 3149 | } |
| 3150 | |
| 3151 | // @join multiple objects into a single object. |
| 3152 | // |