Symbianize Forum

Most of our features and services are available only to members, so we encourage you to login or register a new account. Registration is free, fast and simple. You only need to provide a valid email. Being a member you'll gain access to all member forums and features, post a message to ask question or provide answer, and share or find resources related to mobile phones, tablets, computers, game consoles, and multimedia.

All that and more, so what are you waiting for, click the register button and join us now! Ito ang website na ginawa ng pinoy para sa pinoy!

Serialized and Deserialise json file

tamadsijuan

Professional
Advanced Member
Messages
155
Reaction score
1
Points
28
Mga master pa help naman po masolve ung problem ko

Ex. Json File

{
"ID": 21,
"container": "a",
"created_entity_ids": null,
"child_entity_ids": null,
"content_tier1": {
"owner": {
"lastName": "Dwane",
"firstName": "Chris"
},
"employer": {
"name": "The Pool Company"
},
"payStubPeriodTo": "2018-12-01"
},
"borrower_name": "Dwane, Chris",
"sales_branch": {
"name": "Houston"
},
"processing_branch": {
"name": "Houston"
}
}


My code

Imports System.IO
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim json As String
Dim a As String
Dim b As String
Dim c As String
Dim d As String
Dim g As String
Dim f As String
Dim h As String
Dim i As String
Dim j As String
Dim l As String
json = My.Computer.FileSystem.ReadAllText("C:\JsonTest.Txt")
Dim read = Newtonsoft.Json.Linq.JObject.Parse(json)
TextBox1.Text = read.Item("loan_id").ToString
TextBox2.Text = read.Item("content_tier1").ToString
a = TextBox2.Lines(2).Remove(14)
b = TextBox2.Lines(2).Substring(15)
c = TextBox2.Lines(3).Remove(15)
d = TextBox2.Lines(3).Substring(16)
g = TextBox2.Lines(5).Remove(12)
f = TextBox2.Lines(5).Substring(15)
h = TextBox2.Lines(6).Remove(10)
i = TextBox2.Lines(6).Substring(13)
j = TextBox2.Lines(8).Remove(25)
l = TextBox2.Lines(8).Substring(21)
TextBox3.Text = a
TextBox4.Text = b
TextBox5.Text = c
TextBox6.Text = d
TextBox7.Text = g
TextBox8.Text = f
TextBox9.Text = h
TextBox10.Text = i
TextBox11.Text = j
TextBox12.Text = l
End Sub
End Class

Output dapat nyan is

21 blank
owner blank
lastName "Value"
firstName "value"
employer blank
name "Value"
paystubperiod "value"

ang trigger ko po is si content_tier1 kaso ang nagging output po nya is

21 {

mali na po agad sa simula any advice naman po mga master sensya medyo magulo ata explination ko
 
Hindi ganyan ang mag parse ng Json bro. Ilagay mo sia sa container dapat. parang ganto.

Note: C# code below
Code:
 class Program    {
        static void Main(string[] args)
        {
            using (StreamReader r = new StreamReader(@"C:\yourJson.txt"))
            {
                string json = r.ReadToEnd();
                var items = JsonConvert.DeserializeObject<Data> (json);
            }
        }
    }


    public class Data
    {
        public int ID { get; set; }
        public string container { get; set; }
        public string created_entity_ids { get; set; }
        public string child_entity_ids { get; set; }
        public ContentContainer content_tier1 { get; set; }
        public string borrower_name { get; set; }
        public SalesBranch sales_branch { get; set; }
        public ProcessingBranch processing_branch { get; set; }
    }
 
Back
Top Bottom