Don't reuse Json array when entering new context.

This fixes a segfault when exporting the policy to Json. Basically,
whenever we had a promise type with more than one class selector, we
would enter a new class context by appending the current list of
promises to the json array. However, we did not create a new list of
promises, but kept using the old one, so the same array would be added
several times to the json array. This led to both double free() and
the resulting tree being wrong.

Fixes issue 2151.