I am trying to iterate JSONArray in velocity template
but its not working
I found velocity template can iterate collection, array,hash-map objects
Anyone can help me to iterate JSONArray
Thanks in Advance
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can do this with a custom uberspector. This lets you customize how Velocity interprets gets/sets/iterators.
I did the exact same thing recently for jsonlib. Here’s my uberspector.
JsonArrayIterator is just a simple iterator through the array. if you are using a different JSON library, just customize this class.
The final step is to specify the uberspector in your velocity properties.