public void WriteStructs() { var w = JWriter.New(); WriteStructs(w, ListOfStructs); var s = w.GetString(); }
internal DataKind( string name, SerializerToJWriter internalSerializer, DeserializerFromJReader internalDeserializer) { _name = name; _internalSerializer = internalSerializer; _internalDeserializer = internalDeserializer; _serializer = item => { var w = JWriter.New(); if (item.Item is null) { var obj = w.Object(); obj.Name("version").Int(item.Version); obj.Name("deleted").Bool(true); obj.End(); } else { internalSerializer(item.Item, w); } return(w.GetString()); }; _deserializer = s => { var r = JReader.FromString(s); return(_internalDeserializer(ref r)); }; }
static public void Write(T data) { string current_data; try { current_data = File.ReadAllText(path, Encoding.Default); using (StreamWriter sw = new StreamWriter(path, false, System.Text.Encoding.Default)) { if (data != null) { sw.WriteLine(JWriter <T> .Write(data, current_data)); } else { sw.WriteLine(); } } } catch (System.Exception ex) { throw new System.Exception(ex.Message); } }
public void WriteBools() { var w = JWriter.New(); WriteBools(w, ListOfBools); var s = w.GetString(); }
public string SerializeOutputEvents(object[] events, EventSummary summary, out int eventCountOut) { var jsonWriter = JWriter.New(); var scope = new EventOutputFormatterScope(_config, jsonWriter, _config.InlineUsersInEvents); eventCountOut = scope.WriteOutputEvents(events, summary); return(jsonWriter.GetString()); }
public async Task <IActionResult> Export() { try { using (StreamWriter sw = new StreamWriter("DataFile.json", false, System.Text.Encoding.Default)) { sw.WriteLine(JWriter <List <PoliceStationInfo> > .Write(await db.PoliceStations.Include(s => s.PublicPhone).ToListAsync())); } } catch (Exception ex) { throw new Exception(ex.Message); } return(Ok("Данные экспортированны в формат .json")); }
/// <summary> /// Converts the value to its JSON encoding. /// </summary> /// <remarks> /// For instance, <c>LdValue.Of(1).ToJsonString()</c> returns <c>"1"</c>; /// <c>LdValue.Of("x").ToJsonString()</c> returns <c>"\"x\""</c>; and /// <c>LdValue.Null.ToJsonString()</c> returns <c>"null"</c>. /// </remarks> /// <returns>the JSON encoding of the value</returns> /// <see cref="Parse(string)"/> public string ToJsonString() { switch (_type) { case LdValueType.Null: return("null"); case LdValueType.Bool: return(_boolValue ? "true" : "false"); default: var writer = JWriter.New(); LdJsonConverters.LdValueConverter.WriteJsonValue(this, writer); return(writer.GetString()); } }
internal static string MakeJsonData(FullDataSet data) { var w = JWriter.New(); using (var ow = w.Object()) { foreach (var item in data.Items) { if (item.Value.Item != null) { FeatureFlagJsonConverter.WriteJsonValue(item.Value.Item, ow.Name(item.Key)); } } } return(w.GetString()); }
/// <summary> /// Returns a JSON representation of the user index. /// </summary> /// <returns>the JSON representation</returns> public string Serialize() { var w = JWriter.New(); using (var aw0 = w.Array()) { foreach (var e in Data) { using (var aw1 = aw0.Array()) { aw1.String(e.UserId); aw1.Long(e.Timestamp.Value); } } } return(w.GetString()); }
public async Task <IActionResult> Show() { return(Ok(JWriter <List <PoliceStationInfo> > .Write(await db.PoliceStations.Include(s => s.PublicPhone).ToListAsync()))); }
public async Task <IActionResult> Show() { return(Ok(JWriter <List <TransportNodeInfo> > .Write(await db.TransportNodes.ToListAsync()))); }
public async Task <IActionResult> Show() { return(Ok(JWriter <List <PriorityproductInfo> > .Write(await db.Priorityproducts.ToListAsync()))); }
public async Task <IActionResult> Show() { return(Ok(JWriter <List <FootballFieldInfo> > .Write(await db.FootballFields.Include(s => s.WorkingHoursWinter).ToListAsync()))); }
public async Task <IActionResult> Show() { return(Ok(JWriter <List <RestroomInfo> > .Write(await db.Place.Include(s => s.WorkingHours).ToListAsync()))); }
public EventOutputFormatterScope(EventsConfiguration config, JWriter jw, bool inlineUsers) { _config = config; _jsonWriter = jw; _obj = new ObjectWriter(); }
public async Task <IActionResult> Show() { return(Ok(JWriter <List <HotelInfo> > .Write(await db.Hotels.Include(s => s.ContactPhone).ToListAsync()))); }
public async Task <IActionResult> Show() { return(Ok(JWriter <List <CompetitionsListInfo> > .Write(await db.CompetitionsLists.Include(s => s.WebSite).ToListAsync()))); }