Fix JSON node construction

This fix for an infrequent code path is similar to the one for #4161.