Optimize json_size function

Avoid extra round trip by performing size directly in extract code
Use function binder to cache patterns in call site