Could you provide more details, please? It worked in the simple case I
just tried:
$ ansible localhost -m debug -a "msg='{{ p|to_json }}'" --extra-vars @p.yml
localhost | success >> {
"msg": "[{\"foo\": 1, \"bar\": 2}, {\"buzh\": 42, \"barf\": 2}]"
}
-- Abhijit