How to render json with arbitrary keys using mustache?
问题 I have a JSON object that looks like the following: { "XXX":{"name":"First"}, "YYY":{"name":"Second"}, .... } I need to render it to look like: <div> <h1>XXX</h1> <p>First</p> </div> <div> <h1>YYY</h1> <p>Second</p> </div> .... How will I accomplish this using Mustache? The problem I am facing is that I don't know how to reference the items because the key names are arbitrary. 回答1: Convert the JSON to a hash using your favorite JSON parser, that will give you something that looks like this: