MajorLeagueBaseball / freemarker-json

A Freemarker macro for outputting JSON.
21 stars 14 forks source link

Error: Getting the number of items or enumerating the items is not supported on this sequence+method #1

Open timrobertson100 opened 10 years ago

timrobertson100 commented 10 years ago

I'd love so much for this to work, but sadly I see the following error. It is way beyond my freemarker expertise though.

SEVERE: Error executing FreeMarker template
FreeMarker template error:
Getting the number of items or enumerating the items is not supported on this sequence+method (wrapper: f.e.b.SimpleMethodModel) value.
(Hint 1: Maybe you wanted to call this method first and then do something with its return value. Hint 2: Getting items by intex possibly works, hence it's a "+sequence".)

The failing instruction (FTL stack trace):
----------
==> #local highestIndex = list?size - 1  [in template "WEB-INF/macros/json.ftl" in macro "printList" at line 48, column 3]
    @printList item, has_next_array  [in template "WEB-INF/macros/json.ftl" in macro "printItem" at line 59, column 24]
    #if item?is_enumerable  [in template "WEB-INF/macros/json.ftl" in macro "printItem" at line 58, column 1]
    @printItem hash[key]?if_exists, has_n...  [in template "WEB-INF/macros/json.ftl" in macro "printHashEx" at line 54, column 53]
    #list hash?keys as key  [in template "WEB-INF/macros/json.ftl" in macro "printHashEx" at line 54, column 8]
    @printHashEx data, []  [in template "WEB-INF/macros/json.ftl" in macro "rawStringify" at line 42, column 5]
    #elseif data?is_hash_ex  [in template "WEB-INF/macros/json.ftl" in macro "rawStringify" at line 41, column 3]
    @rawStringify data  [in template "WEB-INF/macros/json.ftl" in macro "stringify" at line 24, column 27]
    @json.stringify occ  [in template "WEB-INF/pages/occurrence/detail.ftl" at line 19, column 27]
----------
ratherblue commented 10 years ago

Ran into something similar today. A sequence+method means that both list?is_method and list?is_sequence are true. You would need to change your code to be list()?size - 1, but check in the backend to see what parameters list() takes,

ratherblue commented 10 years ago

Err, didn't realize this was a library. Need to change item?is_enumerableto item?is_enumerable && !item?is_method.

stutrek commented 10 years ago

Methods are enumerable?