<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Linq;

namespace Salient.ReliableHttpClient.Serialization.Newtonsoft
{
    public class Serializer : Salient.ReliableHttpClient.Serialization.IJsonSerializer
    {
        

        public string SerializeObject(object value)
        {
            return JsonConvert.SerializeObject(value);


        }

        public T DeserializeObject<T>(string json)
        {
            try
            {
                string pattern = "{\\s*\"DateTime\":\\s*\"\\\\/Date\\((?<dt>\\d+)\\)\\\\/\",\\s*\"OffsetMinutes\":\\s*(?<offset>-?\\d+)\\s*}";
                json = Regex.Replace(json, pattern, "\"\\/Date($1+0000)\\/\"");


            }
            catch 
            {
                
                //swallow for now
            }

            return JsonConvert.DeserializeObject<T>(json);
        }
    }
}
<commit_msg>#151 - Revert date format to MS style - /Date(37868276876)/<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Linq;

namespace Salient.ReliableHttpClient.Serialization.Newtonsoft
{
    public class Serializer : Salient.ReliableHttpClient.Serialization.IJsonSerializer
    {
        

        public string SerializeObject(object value)
        {
            //Json.NET 4.5 changed the default dateformatting to ISO 8601 - http://james.newtonking.com/archive/2012/03/20/json-net-4-5-release-1-iso-dates-async-metro-build.aspx
            //Change it back to the previous default of MS style dates i.e - /Date(19372927629377)/
            return JsonConvert.SerializeObject(value, new JsonSerializerSettings{ DateFormatHandling = DateFormatHandling.MicrosoftDateFormat });
        }

        public T DeserializeObject<T>(string json)
        {
            try
            {
                string pattern = "{\\s*\"DateTime\":\\s*\"\\\\/Date\\((?<dt>\\d+)\\)\\\\/\",\\s*\"OffsetMinutes\":\\s*(?<offset>-?\\d+)\\s*}";
                json = Regex.Replace(json, pattern, "\"\\/Date($1+0000)\\/\"");


            }
            catch 
            {
                
                //swallow for now
            }

            return JsonConvert.DeserializeObject<T>(json);
        }
    }
}

{'fraction_non_alphanumeric': 0.14102564102564102, 'fraction_numerical': 0.022035256410256412, 'mean_word_length': 2.012062726176116, 'pattern_counts': {'":': 4, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6651647', 'n_tokens_mistral': 766, 'n_tokens_neox': 715, 'n_words': 126}