CodePaste Logo
New Snippet New Recent Snippets Recent Snippets My Snippets My Snippets My Favorites Favorites Web Code Search Snippets Search
Sign inor Register
Format:
Recent snippets matching tags of json
//Required NewtonSoft.Json
JsonConvert.SerializeObject(); // it will retun string
by hasibul2363   January 28, 2014 @ 9:36pm
Tags: JSON
23 Views
no comments
 
var date = new Date();
console.log(date); // Wed Jan 01 2014 13:28:56 GMT-1000 (Hawaiian Standard Time) 

var json = JSON.stringify(date);
console.log(json);  // "2014-01-01T23:28:56.782Z"  (ISO 8601 encoded JSON string)
      
var dateStr = JSON.parse(json);  
console.log(dateStr); // 2014-01-01T23:28:56.782Z    (parsed into 'plain' js string)

// You can pass an ISO 8601 formatted string to constructor
by Rick Strahl   January 01, 2014 @ 3:52pm
304 Views
no comments
 
C#
// put in WebApiConfig.Register()
GlobalConfiguration.Configuration.Formatters
    .JsonFormatter
    .SerializerSettings
    .Converters.Add(new StringEnumConverter());
by Rick Strahl   November 02, 2013 @ 2:11am
466 Views
no comments
 
C#
Install-Package Newtonsoft.Json


using Newtonsoft.Json;

// Instantiate obj
			PhdStudent objPhDStudent = new PhdStudent()
			{
				Age = 35,
				Credits = 25,
by Jose David Parra   August 06, 2013 @ 4:23pm
247 Views
no comments
 
C#
// JavaScript Code
$().ready(function () {

    ajaxCallMethod("CallbackHandler.ashx?", "GetDate",
    [{ Name: "Rick", Entered: new Date(2012,0,1) }],
    function (result) {
        alert(result);
    });

    ajaxCallMethod("CallbackHandler.ashx?", "GetDate",
by Rick Strahl   March 19, 2012 @ 4:38pm
240 Views
no comments
 
 ajaxCallMethod("CallbackHandler.ashx?", "Test",
             [{ Entered: "03/15/2010", Name: "Rick"}],
             function (result) {
                 alert(result);
             });
ajaxCallMethod("CallbackHandler.ashx?", "Test",
             [{ Entered: new Date(2010,2,15), Name: "Rick"}],
             function (result) {
                 alert(result);
             });
by Rick Strahl   March 19, 2012 @ 2:10pm
204 Views
no comments
 
C#
using System;
using System.Net.Http.Formatting;
using System.Threading.Tasks;
using System.Web.Script.Serialization;
using System.Json;
using System.IO;

namespace Westwind.Web.WebApi
{
    public class JavaScriptSerializerFormatter : MediaTypeFormatter
by Rick Strahl   March 08, 2012 @ 5:17pm
1055 Views
no comments
 
/* Google jquery CDN 
 <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script> */
   
            $.ajax(
            {
                type: "POST",
                contentType: "application/json; charset=utf-8",
                url: "services/FeedService.svc/ServiceMethod",
                data: '{"param1":"data1" , "param2":"data2"}',
                dataType: "json",
by frank2tek   October 04, 2011 @ 11:25am
238 Views
no comments
 
/// <reference path="jquery.js" />
/*
ServiceProxy.js  
Version 0.981 - 4/5/11

(c) 2008-2011 Rick Strahl, West Wind Technologies 
www.west-wind.com

Load json2.js before this library
http://github.com/douglascrockford/JSON-js/blob/master/json2.js
by Rick Strahl   April 12, 2010 @ 6:40pm
Tags: JSON, Ajax, Date, ASMX, WCF
6470 Views
no comments
 
if (JSON && !JSON.parseWithDate) {
    var reISO = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/;
    var reMsAjax = /^\/Date\((d|-|.*)\)[\/|\\]$/;

    JSON.parseWithDate = function(json) {
        /// <summary>
        /// parses a JSON string and turns ISO or MSAJAX date strings
        /// into native JS date objects
        /// </summary>    
        /// <param name="json" type="var">json with dates to parse</param>        
by Rick Strahl   September 15, 2009 @ 3:31pm
1762 Views
no comments
 
C#
[TestClass]
public class DateConversionTests
{
    public DateConversionTests()
    {
    }        


    [TestMethod]
    public void AjaxDate_IsoDate_DataContract_DeserializationTest()
by Rick Strahl   September 15, 2009 @ 12:46pm
1299 Views
no comments
 
brought to you by:
West Wind Techologies