Extract JSON marshalling

TO prepare the client to support all different formats (text and
protobuf specifically), this commit extracts the depreacted JSON format
from the core code.
Rename special name label to __name__

As the metric name is just a special label, it needs to be distinguished
from custom user labels with the name "name".

This reflects the breaking JSON change made in [1].

[1]: https://github.com/prometheus/client_golang/commit/bb957bc