Click here to Skip to main content
14,868,965 members
Home / Discussions / C#
   

C#

 
GeneralRe: User Control Pin
Member 147923938-Mar-21 1:49
MemberMember 147923938-Mar-21 1:49 
AnswerRe: User Control Pin
Ralf Meier7-Mar-21 22:46
professionalRalf Meier7-Mar-21 22:46 
GeneralRe: User Control Pin
BillWoodruff8-Mar-21 1:07
mveBillWoodruff8-Mar-21 1:07 
GeneralRe: User Control Pin
Member 147923938-Mar-21 1:51
MemberMember 147923938-Mar-21 1:51 
GeneralRe: User Control Pin
Ralf Meier8-Mar-21 5:10
professionalRalf Meier8-Mar-21 5:10 
QuestionHow to take JSON POST data and covert it to something i can work with Pin
jacobarrey4-Mar-21 11:40
Memberjacobarrey4-Mar-21 11:40 
AnswerRe: How to take JSON POST data and covert it to something i can work with Pin
OriginalGriff4-Mar-21 11:45
mveOriginalGriff4-Mar-21 11:45 
GeneralRe: How to take JSON POST data and covert it to something i can work with Pin
jacobarrey5-Mar-21 9:37
Memberjacobarrey5-Mar-21 9:37 
Lol im completely new to JSON so sorry for not knowing exactly what its supposed to do Smile | :) Heres the code to convert it to classes. I used quicktype.io to help me
<pre>// <auto-generated />
//
// To parse this JSON data, add NuGet 'Newtonsoft.Json' then do:
//
//    using quicktype;
//
//    var welcome = Welcome.FromJson(jsonString);

namespace quicktype
{
    using System;
    using System.Collections.Generic;

    using System.Globalization;
    using Newtonsoft.Json;
    using Newtonsoft.Json.Converters;

    public partial class Welcome
    {
        [JsonProperty("PropertyInfos")]
        public List<PropertyInfo> PropertyInfos { get; set; }
    }

    public partial class PropertyInfo
    {
        [JsonProperty("Identification")]
        public Identification Identification { get; set; }

        [JsonProperty("PropertyName")]
        public string PropertyName { get; set; }

        [JsonProperty("ManagementCompany")]
        public ManagementCompany ManagementCompany { get; set; }

        [JsonProperty("Address")]
        public Address Address { get; set; }
    }

    public partial class Address
    {
        [JsonProperty("Address")]
        public string AddressAddress { get; set; }

        [JsonProperty("City")]
        public string City { get; set; }

        [JsonProperty("State")]
        public string State { get; set; }

        [JsonProperty("PostalCode")]
        [JsonConverter(typeof(ParseStringConverter))]
        public long PostalCode { get; set; }

        [JsonProperty("Email")]
        public string Email { get; set; }
    }

    public partial class Identification
    {
        [JsonProperty("IDValue")]
        [JsonConverter(typeof(ParseStringConverter))]
        public long IdValue { get; set; }
    }

    public partial class ManagementCompany
    {
        [JsonProperty("ManagementCompanyName")]
        public string ManagementCompanyName { get; set; }

        [JsonProperty("Identification")]
        public Identification Identification { get; set; }
    }

    public partial class Welcome
    {
        public static Welcome FromJson(string json) => JsonConvert.DeserializeObject<Welcome>(json, quicktype.Converter.Settings);
    }

    public static class Serialize
    {
        public static string ToJson(this Welcome self) => JsonConvert.SerializeObject(self, quicktype.Converter.Settings);
    }

    internal static class Converter
    {
        public static readonly JsonSerializerSettings Settings = new JsonSerializerSettings
        {
            MetadataPropertyHandling = MetadataPropertyHandling.Ignore,
            DateParseHandling = DateParseHandling.None,
            Converters =
            {
                new IsoDateTimeConverter { DateTimeStyles = DateTimeStyles.AssumeUniversal }
            },
        };
    }

    internal class ParseStringConverter : JsonConverter
    {
        public override bool CanConvert(Type t) => t == typeof(long) || t == typeof(long?);

        public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
        {
            if (reader.TokenType == JsonToken.Null) return null;
            var value = serializer.Deserialize<string>(reader);
            long l;
            if (Int64.TryParse(value, out l))
            {
                return l;
            }
            throw new Exception("Cannot unmarshal type long");
        }

        public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
        {
            if (untypedValue == null)
            {
                serializer.Serialize(writer, null);
                return;
            }
            var value = (long)untypedValue;
            serializer.Serialize(writer, value.ToString());
            return;
        }

        public static readonly ParseStringConverter Singleton = new ParseStringConverter();
    }
}


Now ive created a class in c# where i can access these classes. How do i get JSON to put my POST data into these classes. Or are you able to point me to a video, guide, etc that could help me learn this
GeneralRe: How to take JSON POST data and covert it to something i can work with Pin
OriginalGriff5-Mar-21 10:57
mveOriginalGriff5-Mar-21 10:57 
AnswerRe: How to take JSON POST data and covert it to something i can work with Pin
smartial_arts17-Mar-21 15:15
Membersmartial_arts17-Mar-21 15:15 
QuestionC# - TCP/IP COMMUNICATIONS Pin
ICARUS9993-Mar-21 9:58
MemberICARUS9993-Mar-21 9:58 
AnswerRe: C# - TCP/IP COMMUNICATIONS Pin
shanda watkins3-Mar-21 10:15
Membershanda watkins3-Mar-21 10:15 
AnswerRe: C# - TCP/IP COMMUNICATIONS Pin
BillWoodruff3-Mar-21 19:00
mveBillWoodruff3-Mar-21 19:00 
Questionhow to create RDLC report for windows application C# Pin
Meax3-Mar-21 6:03
MemberMeax3-Mar-21 6:03 
AnswerRe: how to create RDLC report for windows application C# Pin
shanda watkins3-Mar-21 10:17
Membershanda watkins3-Mar-21 10:17 
GeneralRe: how to create RDLC report for windows application C# Pin
Meax3-Mar-21 17:27
MemberMeax3-Mar-21 17:27 
SuggestionRe: how to create RDLC report for windows application C# Pin
shanda watkins4-Mar-21 0:58
Membershanda watkins4-Mar-21 0:58 
AnswerRe: how to create RDLC report for windows application C# Pin
Richard MacCutchan3-Mar-21 21:13
mveRichard MacCutchan3-Mar-21 21:13 
QuestionMirror a Website using Blazor Pin
GerVenson3-Mar-21 1:43
professionalGerVenson3-Mar-21 1:43 
GeneralHacking Pin
Member 1508659528-Feb-21 21:22
MemberMember 1508659528-Feb-21 21:22 
GeneralRe: Hacking Pin
OriginalGriff28-Feb-21 21:23
mveOriginalGriff28-Feb-21 21:23 
GeneralRe: Hacking Pin
Maximilien1-Mar-21 9:45
MemberMaximilien1-Mar-21 9:45 
GeneralRe: Hacking Pin
OriginalGriff1-Mar-21 10:28
mveOriginalGriff1-Mar-21 10:28 
GeneralRe: Hacking Pin
trønderen2-Mar-21 8:57
Membertrønderen2-Mar-21 8:57 
GeneralRe: Hacking Pin
SawmillTurtle1-Mar-21 9:17
MemberSawmillTurtle1-Mar-21 9:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.