@@ -216,16 +216,8 @@ func marshalJson(input interface{}) (string, error) {
216216 return strings .TrimSuffix (buf .String (), "\n " ), nil
217217}
218218
219- func unmarshalJsonArray (input string ) ([]interface {}, error ) {
220- var v []interface {}
221- if err := json .Unmarshal ([]byte (input ), & v ); err != nil {
222- return nil , err
223- }
224- return v , nil
225- }
226-
227- func unmarshalJsonObject (input string ) (interface {}, error ) {
228- var v map [string ]interface {}
219+ func unmarshalJson (input string ) (interface {}, error ) {
220+ var v interface {}
229221 if err := json .Unmarshal ([]byte (input ), & v ); err != nil {
230222 return nil , err
231223 }
@@ -301,34 +293,33 @@ func trimSuffix(suffix, s string) string {
301293
302294func newTemplate (name string ) * template.Template {
303295 tmpl := template .New (name ).Funcs (template.FuncMap {
304- "closest" : arrayClosest ,
305- "coalesce" : coalesce ,
306- "contains" : contains ,
307- "dict" : dict ,
308- "dir" : dirList ,
309- "exists" : exists ,
310- "first" : arrayFirst ,
311- "groupBy" : groupBy ,
312- "groupByKeys" : groupByKeys ,
313- "groupByMulti" : groupByMulti ,
314- "hasPrefix" : hasPrefix ,
315- "hasSuffix" : hasSuffix ,
316- "json" : marshalJson ,
317- "intersect" : intersect ,
318- "keys" : keys ,
319- "last" : arrayLast ,
320- "replace" : strings .Replace ,
321- "parseJsonArray" : unmarshalJsonArray ,
322- "parseJsonObject" : unmarshalJsonObject ,
323- "sha1" : hashSha1 ,
324- "split" : strings .Split ,
325- "trimPrefix" : trimPrefix ,
326- "trimSuffix" : trimSuffix ,
327- "where" : where ,
328- "whereExist" : whereExist ,
329- "whereNotExist" : whereNotExist ,
330- "whereAny" : whereAny ,
331- "whereAll" : whereAll ,
296+ "closest" : arrayClosest ,
297+ "coalesce" : coalesce ,
298+ "contains" : contains ,
299+ "dict" : dict ,
300+ "dir" : dirList ,
301+ "exists" : exists ,
302+ "first" : arrayFirst ,
303+ "groupBy" : groupBy ,
304+ "groupByKeys" : groupByKeys ,
305+ "groupByMulti" : groupByMulti ,
306+ "hasPrefix" : hasPrefix ,
307+ "hasSuffix" : hasSuffix ,
308+ "json" : marshalJson ,
309+ "intersect" : intersect ,
310+ "keys" : keys ,
311+ "last" : arrayLast ,
312+ "replace" : strings .Replace ,
313+ "parseJson" : unmarshalJson ,
314+ "sha1" : hashSha1 ,
315+ "split" : strings .Split ,
316+ "trimPrefix" : trimPrefix ,
317+ "trimSuffix" : trimSuffix ,
318+ "where" : where ,
319+ "whereExist" : whereExist ,
320+ "whereNotExist" : whereNotExist ,
321+ "whereAny" : whereAny ,
322+ "whereAll" : whereAll ,
332323 })
333324 return tmpl
334325}
0 commit comments