Beispiel #1
0
        HttpResponseMessage BuildResponse()
        {
            // This simple example generates JSON that holds
            // information about the current time.

            // The current time in UTC.
            DateTime current = System.DateTime.UtcNow;

            // Build JSON manually.
            string json =
                "{\n" +
                $"  \"year\":        {current.Year},\n" +
                $"  \"month\":       {current.Month},\n" +
                $"  \"day\":         {current.Day},\n" +
                $"  \"hour\":        {current.Hour},\n" +
                $"  \"minute\":      {current.Minute},\n" +
                $"  \"second\":      {current.Second},\n" +
                $"  \"millisecond\": {current.Millisecond}\n" +
                "}\n";

            // "200 OK", "application/json;charset=UTF-8"
            return(ResponseUtility.OkJson(json));
        }