Json with c# form [duplicate] - c#

This question already has answers here:
How can I deserialize JSON with C#?
(19 answers)
Closed 5 years ago.
i have this json with data
http://84.235.49.85:58/saws/hi/is/inserSer?jsonObject={
"authObject":{
"userName":"7070",
"password":"123",
"baladyCode":"07",
"amanaCode":"061"
},
"billObj":{
"billNumber":"0611138000302",
"billCreationDate":"07-01-1438",
"billDetails":[
{"depId":"11006","billValue":"1"}
]}
}
authObject Obj:-
this object holds authentication data about user that will be used to decide can we allow accessing for this request or not.
billObj Obj:-
this object holds bill data that will be used to create insertion operation, let us say that every bill may have one sub-account or many sub-accounts so we make it dynamic and give you to create Json Array of bill's details that holds every sub-account and its value
any one help me for creating this code in c# form . i need full code for this example please .thanks

You must use a library for that.
I recommend you Newtonsoft.JSON
It's easy to use, and you can download it via nuget.
You must create a class and just fun!
ej: https://pastebin.com/6sVd1TF0

Related

Is there any way to get my json without creating a class [duplicate]

This question already has answers here:
How do you read a simple value out of some json using System.Text.Json?
(8 answers)
Closed 11 months ago.
From an API call I am getting some JSON data, I dont want to declare a class, while in NewtonSoft we can get those data as given below without creating a class,
JObject o1 = JObject.Parse(File.ReadAllText(#"example.json"));
Console.WriteLine(o1["customername"]);
Is there any similar way to get json data without creating a class in System.Text.Json
Edit:
I was able to proceed by the solutions provided here
How do you read a simple value out of some json using System.Text.Json?
You could try using JSON document model and parse subsections you are interested in.
See this link https://learn.microsoft.com/en-us/dotnet/standard/serialization/system-text-json-use-dom-utf8jsonreader-utf8jsonwriter?pivots=dotnet-6-0#deserialize-subsections-of-a-json-payload

C# .Net4.5 API/Library method reference description inside source code [duplicate]

This question already has answers here:
Programmatically get Summary comments at runtime
(7 answers)
Closed 4 years ago.
I want to retrieve the method description inside my code. I used reflection to extract the name of the methods used in a project (used MemberInfo.GetMethod() for this). Now, I want to get the description for each of the methods extracted from the tool. Actually, I want to have the API reference descriptions made available by MSDN: https://learn.microsoft.com/en-ca/dotnet/api/?view=netframework-4.7.1.
This description comes up if we take the cursor on the method name in VS2015 IDE, but I want to get these descriptions with help of coding (Something like query with method name and have reference descriptions for that queried method). I have done this with Java and Python, but haven't found anything in C#. Please help me to figure out my problem.
I don't think that's generally possible. The description from MSDN is basically the summary and is not stored in the assembly. Also see this awnser.

Out-of-the-box JSON equivalent for C# and Unity 3D [duplicate]

This question already has answers here:
Need a JSON parser for Unity3d
(2 answers)
Serialize and Deserialize Json and Json Array in Unity
(9 answers)
Closed 5 years ago.
I'm building a game and I need to store multiple data about levels:
A list of strings for dialogs
An int for the countdown time of each level
A float for right answer
Strings for dynamically loaded asset names.
probably some other data..
Coming from a web background, the most obvious path is to make this with JSON, but Unity 3D does not provide JSON support out of the box.. so I thought of XML, but still, no native support.. then I thought about multidimentional array, but there are limitations, such as the data types must be the same.
As a student, I want to do things according to the development pattern of the engine without external libraries, and my question is How do Unity Game Developers store data like this? What is the best way to deal with this problem?

JSON field's names in the Web Service response [duplicate]

This question already has answers here:
Serializing F# Record type to JSON includes '#' character after each property
(2 answers)
Closed 7 years ago.
I use F#, but I believe the question is not F# specific.
I have the interface for Web Service:
[<ServiceContract>]
type IRestService =
[<OperationContract>]
[<WebGet(UriTemplate = "Maintenance", ResponseFormat=WebMessageFormat.Json)>]
abstract GetMaintenancesRest: a:unit -> Maintenance[]
When I am trying to use this service I can get JSON, but all field's names in the JSON have the symbol '#':
[{"Address#":"one","Assetid#":"","Assignmentdate#":"/Date(1434147917730-0700)/","Comment#":"" ...
Why and how can I fix it?
It's F#. I ran into this a long time ago, so I might be forgetting. As I recall you may not use records to return from the service, or you get this error. You need class types with properties. I don't think mutable records work either. I also don't think public fields work; it's got to be public read/write properties.

Regarding Serialization in JAVA, C# etc [duplicate]

This question already has answers here:
What is the need of serialization of objects in Java? [closed]
(9 answers)
Closed 9 years ago.
I have been reading through all that I could find to understand what Serialization is. People often say that we need serialization so that we can convert the in-memory object into a form that is easy to transport over the network and persist on the disk.
My question is - What is so wrong with the in-memory object's structure that makes it difficult to be transported or stored?
Some people also say that the object is binary in form and needs to be serialized. AFAIK, everything in the computer storage or memory is binary. What is it that they want to convey?
Some technical details would be appreciated.
EDIT 1:
I have been looking into C# code samples but all of them use the "Serialization" available in the framework. Maybe I need to work with C++ to see the details and to experience the pain.
A simple and obvious example; a file object is a reference to a file in the file system, but in itself not very useful. Serializing it will at best pass a filename to the receiver, which may not have the file system to read the file from.
Instead, when you pass it over the network, you can serialize it to instead contain the contents of the file, which is usable by the receiver.
Serializing is basically just taking an object which in memory may not have very usable content (pointers/references to data stored elsewhere/...), and converting it to something that is actually usable by the receiver.
For instance, if you have an object of this class
public class myClass {
private String myString = null;
// getters and setters
}
The in memory representation will be the just a pointer to another object (the String). You cannot recall the original state of the object just by storing the binary form.

Categories