public static T Deserialize <T>(string data, Jil.Options options = null) { using (var input = new StringReader(data)) { return(Jil.JSON.Deserialize <T>(input, options)); } }
public static void Serialize <T>(T data, Stream stream, Jil.Options options = null) { using (var writer = new StreamWriter(stream)) { Jil.JSON.Serialize(data, writer, options); } }
public JilFormatter() { _jilOptions = new Options(dateFormat: DateTimeFormat.ISO8601,includeInherited:true); SupportedMediaTypes.Add(new MediaTypeHeaderValue("application/json")); SupportedEncodings.Add(new UTF8Encoding(encoderShouldEmitUTF8Identifier: true, throwOnInvalidBytes: true)); SupportedEncodings.Add(new UnicodeEncoding(bigEndian:false,byteOrderMark:true,throwOnInvalidBytes:true)); }
public void ElasticExampleFailure() { var mainQuery = new _ElasticExampleFailure(); var filterQuery = new _ElasticExampleFailure() { _cache = true }; filterQuery.AddMustNot(new { term = new { blocking = 1234 }, }); mainQuery.AddMust(_ElasticExampleFailure.BuildSkillsQuery("Dean Ward")); object filteredQuery = new { query = new { @bool = mainQuery }, filter = new { @bool = filterQuery } }; object queryObject = new { from = 0, size = 30, query = new { filtered = filteredQuery }, }; var options = new Options(prettyPrint: true); var res = JSON.SerializeDynamic(queryObject, options); Assert.AreEqual("{\n \"size\": 30,\n \"from\": 0,\n \"query\": {\n \"filtered\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\n \"must\": null,\n \"must_not\": null,\n \"should\": [{\n \"query_string\": {\n \"use_dis_max\": true,\n \"fields\": [\"personalStatement\", \"yearsOfExperienceTags^1.5\", \"stackExchangeAnswersTags^0.1\", \"name\", \"likeTags\", \"stackOverflowUserName\", \"projects.projectName\", \"projects.projectTags\", \"projects.projectDescription\", \"experience.experienceJobTitle\", \"experience.experienceEmployerName\", \"experience.experienceTags\", \"experience.experienceResponsibilities\", \"education.educationInstitution\", \"education.educationTags\", \"education.educationDegreeName\", \"education.educationAchievements\"],\n \"default_operator\": \"AND\",\n \"query\": \"Dean Ward\"\n }\n }],\n \"_cache\": null,\n \"boost\": null,\n \"minimum_number_should_match\": 1\n }],\n \"must_not\": null,\n \"should\": null,\n \"_cache\": null,\n \"boost\": null,\n \"minimum_number_should_match\": null\n }\n },\n \"filter\": {\n \"bool\": {\n \"must\": null,\n \"must_not\": [{\n \"term\": {\n \"blocking\": 1234\n }\n }],\n \"should\": null,\n \"_cache\": true,\n \"boost\": null,\n \"minimum_number_should_match\": null\n }\n }\n }\n }\n}", res); }
public JilCommandSerializer() { m_jilOptions = new Options( includeInherited: true, dateFormat: DateTimeFormat.ISO8601, unspecifiedDateTimeKindBehavior: UnspecifiedDateTimeKindBehavior.IsUTC); }
//private HttpClient client { set; get; } public MedicalInsuranceController() { //client = new HttpClient((HttpMessageHandler)new HttpClientHandler(),disposeHandler:false); //client.Timeout = TimeSpan.FromSeconds(Int32.Parse(timeOut)); //参数为数据库的用户名 connectionString = OracleConnectionData.ConnectionString; option = new Options(excludeNulls: true, includeInherited: true); }
public JilFormatter() { _jilOptions = new Jil.Options(dateFormat: DateTimeFormat.ISO8601, includeInherited: true); SupportedMediaTypes.Add(new MediaTypeHeaderValue("application/json")); SupportedEncodings.Add(new UTF8Encoding(false, true)); SupportedEncodings.Add(new UnicodeEncoding(false, true, true)); }
/// <summary> /// Configures the <see cref="Options"/> to use. /// </summary> /// <param name="config">The configuration object.</param> /// <param name="options">The <see cref="Options"/> to use.</param> public static void Options(this SerializationExtentions<JilSerializer> config, Options options) { if (options == null) { throw new ArgumentNullException("options"); } config.GetSettings().Set<Options>(options); }
public JilFormatter() { _options = new Options(dateFormat:DateTimeFormat.ISO8601,serializationNameFormat:SerializationNameFormat.CamelCase); SupportedMediaTypes.Add(new MediaTypeHeaderValue("application/json")); SupportedEncodings.Add(new UTF8Encoding(false, true)); SupportedEncodings.Add(new UnicodeEncoding(false, true, true)); }
public void SetSerializer(IDictionary<string, string> settings, BusConfiguration builder) { var options = new Options( dateFormat: DateTimeFormat.MicrosoftStyleMillisecondsSinceUnixEpoch, includeInherited: true); builder.UseSerialization<JilSerializer>().Options(options); }
public JilFormatter(Options options) { this.options = options; SupportedMediaTypes.Add(applicationJsonMediaType); SupportedMediaTypes.Add(textJsonMediaType); SupportedEncodings.Add(new UTF8Encoding(false, true)); SupportedEncodings.Add(new UnicodeEncoding(false, true, true)); }
public JilSerializer(JilOptions options) { if (options == null) { throw new ArgumentNullException(nameof(options)); } _settings = options; }
/// <summary> /// Configures Rebus to use the simple and extremely fast Jil JSON serializer. Pass an <see cref="JilNs.Options"/> object to specify /// the particulars (such as <see cref="DateTime"/>/<see cref="DateTimeOffset"/> formats) of the JSON being serialized/deserialized. /// If omitted <see cref="JilNs.Options.Default"/> is used, unless <see cref="JilNs.JSON.SetDefaultOptions"/> has been called with a different /// <see cref="JilNs.Options"/> object. /// </summary> public static void UseJil(this StandardConfigurer <ISerializer> configurer, JilNs.Options options = null) { if (configurer == null) { throw new ArgumentNullException(nameof(configurer)); } configurer.Register(c => new Jil.JilSerializer(options)); }
public JilFormatter() { _jilOptions = new Options(dateFormat: DateTimeFormat.ISO8601); SupportedMediaTypes.Add(new MediaTypeHeaderValue("application/json")); SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/html")); // added by Kel. text/html allows us to view JSON directly in browser even we don't use tools such as REST Console SupportedEncodings.Add(new UTF8Encoding(encoderShouldEmitUTF8Identifier: false, throwOnInvalidBytes: true)); SupportedEncodings.Add(new UnicodeEncoding(bigEndian: false, byteOrderMark: true, throwOnInvalidBytes: true)); }
static void Run(Options options) { var jsonOptions = new Jil.Options( serializationNameFormat: SerializationNameFormat.CamelCase, includeInherited: true ); JSON.SetDefaultOptions(jsonOptions); var URIs = options.Listeners.ToArray(); var schema = LoadSchema(options.LoadSchemaFromStdIn); var host = WebHost.CreateDefaultBuilder() .UseUrls(URIs) .ConfigureServices(services => ConfigureServices(services, options, schema)) .Configure(app => Configure(app)) .Build(); host.Run(); }
public static T Deserialize <T>(Stream stream, Jil.Options options = null) { using TextReader text = new StreamReader(stream); return(Jil.JSON.Deserialize <T>(text, options)); }
public GZipJilContentFormatter(Options options, Encoding encoding, string mediaType = "application/json", string ext = "json") : base(mediaType, ext, encoding) { this.options = options; }
public GZipJilContentFormatter(Options options, string mediaType = "application/json", string ext = "json") : this(options, new UTF8Encoding(false), mediaType, ext) { }
public static dynamic Deserialize(string source, Jil.Options options = null) { return(JSON.DeserializeDynamic(source, options)); }
public static object Deserialize(string source, Type destinationType, Jil.Options options = null) { return(JSON.Deserialize(source, destinationType, options)); }
public static T Deserialize <T>(string source, Jil.Options options = null) { return(JSON.Deserialize <T>(source, options)); }
public static string Serialize <T>(T source, Jil.Options options = null) { return(JSON.Serialize(source, options)); }
public JilResult() { // 指定日期格式 JilOptions = new Options(dateFormat: DateTimeFormat.ISO8601); }
private static Options GetDefaultOptions() { var opt = new Options(excludeNulls: true, dateFormat: DateTimeFormat.ISO8601); return opt; }
public static string Serialize <T>(T data, Jil.Options options = null) { return(Jil.JSON.Serialize(data, options)); }
private static void CompareTimes <T>(List <T> toSerialize, Jil.Options opts, Func <TextReader, int, T> a, Func <TextReader, int, T> b, out double aTimeMS, out double bTimeMS) { var asStrings = toSerialize.Select(o => Jil.JSON.Serialize(o, opts)).ToList(); var aTimer = new Stopwatch(); var bTimer = new Stopwatch(); Action timeA = () => { aTimer.Start(); for (var i = 0; i < asStrings.Count; i++) { using (var str = new StringReader(asStrings[i])) { a(str, 0); } } aTimer.Stop(); }; Action timeB = () => { bTimer.Start(); for (var i = 0; i < asStrings.Count; i++) { using (var str = new StringReader(asStrings[i])) { b(str, 0); } } bTimer.Stop(); }; for (var i = 0; i < 5; i++) { timeA(); timeB(); } bTimer.Reset(); aTimer.Reset(); for (var i = 0; i < 100; i++) { var order = (i % 2) == 0; if (order) { timeA(); timeB(); } else { timeB(); timeA(); } } aTimeMS = aTimer.ElapsedMilliseconds; bTimeMS = bTimer.ElapsedMilliseconds; }