Click here to Skip to main content
15,889,462 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
{
    "Record": [
        {
            "Wagon_Details": [
                {
                    "Rake_No1": "",
                    "Rake_No2": "",
                    "Rake_ID": "",
                    "SL_No": "",
                    "Wagon_rly": "",
                    "Wagon_type": "",
                    "Wagon_no": "",
                    "Wagon_flag": "",
                    "Wagon_tare": "",
                    "Wagon_gross": "",
                    "Wagon_net": "",
                    "Wagon_over_load": " ",
                    "Speed": " ",
                    "No_of_axel": " ",
                    "MobileNumber": " ",
                    "Weigh_datetime": " ",
                    "Status_flag": " ",
                    "Remarks": " "
                }
            ],
            "Rake_Data": [
                {
                    "Rake_no1": " ",
                    "Rake_no2": " ",
                    "Rake_id": " ",
                    "Rake_name": " ",
                    "Local_id": " ",
                    "Sttn_from": " ",
                    "Sttn_to": " ",
                    "cnsg": " ",
                    "cnsr": " ",
                    "Arvl_time": " ",
                    "Line_no": " ",
                    "Lead_loco": " ",
                    "Actlunts": " ",
                    "No_of_wagon": " ",
                    "Commmodity": " ",
                    "Fois_save_datetime": " ",
                    "Loaded_on": " ",
                    "Status_flag": " ",
                    "Gross_datetime": " ",
                    "Tare_datetime": " ",
                    "Last_print": " ",
                    "Direction": " ",
                    "Total_net": " ",
                    "Gross_by": " ",
                    "Merged_by": " ",
                    "Tare_by": " ",
                    "Added_by": " ",
                    "Weigh_type": " ",
                    "Weigh_start": " ",
                    "Weigh_end": " ",
                    "Weigh_mode": " ",
                    "T_id": " ",
                    "G_id": " "
                }
            ]
        }
    ]
}


What I have tried:

Yes,I am try, but not done, I am new in impelementing API In VB.net
Posted
Updated 25-May-22 20:02pm
v2

1 solution

What you have created isn't really JSON - it's a "map" of a couple of objects which almost certainly have the wrong value types embedded in them.

JSON isn't about "class descriptions" it's about data transfer - a JSON text is a set of object instances which can be rebuilt into the same classes at the destination.

Your JSON sample can't do that: every field in the class would be of type object or string, instead of DateTime, int, or double

What I'd suggest is that you get actual data samples, and feed them to an online converter like this one: JSON Utils: Generate C#, VB.Net, SQL TAble and Java from JSON[^] which will give you VB Classes you can modify to the correct datatypes.
Then use a JSON reader in your app (I use Json.NET - Newtonsoft[^] which you can add via NuGet) to deserialize the data directly into useful class instances.
 
Share this answer
 
Comments
Member 11004533 26-May-22 2:08am    
Actually, I am implement rest API using VB.NET, when i call API and sent the data to server, the data format should be in JSON format, details given below

https://xxxttyyy.weeebuuu.in:8000/RESTAdapter/XPI/XYZDetails
Credentials

User Id-USERNAME
Pass-myP@ssw0rd



{
"Record": [
{
"Wagon_Details": [
{
"Rake_No1": "",
"Rake_No2": "",
"Rake_ID": "",
"SL_No": "",
"Wagon_rly": "",
"Wagon_type": "",
"Wagon_no": "",
"Wagon_flag": "",
"Wagon_tare": "",
"Wagon_gross": "",
"Wagon_net": "",
"Wagon_over_load": " ",
"Speed": " ",
"No_of_axel": " ",
"MobileNumber": " ",
"Weigh_datetime": " ",
"Status_flag": " ",
"Remarks": " "
}
],
"Rake_Data": [
{
"Rake_no1": " ",
"Rake_no2": " ",
"Rake_id": " ",
"Rake_name": " ",
"Local_id": " ",
"Sttn_from": " ",
"Sttn_to": " ",
"cnsg": " ",
"cnsr": " ",
"Arvl_time": " ",
"Line_no": " ",
"Lead_loco": " ",
"Actlunts": " ",
"No_of_wagon": " ",
"Commmodity": " ",
"Fois_save_datetime": " ",
"Loaded_on": " ",
"Status_flag": " ",
"Gross_datetime": " ",
"Tare_datetime": " ",
"Last_print": " ",
"Direction": " ",
"Total_net": " ",
"Gross_by": " ",
"Merged_by": " ",
"Tare_by": " ",
"Added_by": " ",
"Weigh_type": " ",
"Weigh_start": " ",
"Weigh_end": " ",
"Weigh_mode": " ",
"T_id": " ",
"G_id": " "
}
]
}
]
}
OriginalGriff 26-May-22 3:26am    
Fine - so create the date in appropriate classes, then use Newtonsoft to serialize the actual instance(s) to a JSON string.

What part of this is giving you difficulties?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900