[json] Recurse less when encoding to JSON