Refactor JSON support funtions.

Refactor JSON export function to escape characters when encoding a
string object and add a new function to import JSON data.
Move both functions to common tools directory.
Move lowlevel NetCDF functions to common tools.