node.js return json

Step 1: Import the 'http' module to create an HTTP server. Step 2: Create a server using the 'createServer' method of the 'http' module. Step 3: Set the response type to 'application/json' to indicate that the server will return JSON. Step 4: Create a JSON object with the data to be returned. Step 5: Convert the JSON object to a string using 'JSON.stringify'. Step 6: Write the JSON string to the response. Step 7: End the response. Step 8: Make the server listen on a specified port, e.g., 3000.