Code generation for Jackson stream parsing with live template

I would like to use live template to generate stream parsing code.

Below is what I want to achieve, assume there is a json,
{
     "type":1,
     "content":"abc"
     .....
}

In Intellij, I would like to generate code to parse above Json. I type
{"type","content", ....}
then .<template> name and press Tab. Intellij generates code as below

//----Start generated code-----

      while(parser.nextToken() != JsonToken.END_OBJECT){
            String fieldName = parser.getCurrentName();
            // Let's move to value
            parser.nextToken();

            if("type".equals(fieldName)){
                //Tab selection
            }else if("content".equals(fieldName)){
                 //Tab selection
            }
            ............
            else{
                parser.skipChildren();
            }
        }
//----End generated code-----

I found that such as  $ARRAY$[$INDEX$], but there is no way to evaluate the value of the variable.
Do anyone have an idea to write such live template? Thanks!

Please sign in to leave a comment.