Extraction of values from SQL, conversion to JSON.