Click here to Skip to main content
15,882,017 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hi,i added webservice in xamarin form project, and after send request i got the result in object but when i added code to serialaize and deserialaize object i got error,
how can i read result of request ?

What I have tried:

C#
var servico = new de.xxxx.wsm.WebService();
object Obj = servico.WsmPersCur(new WsmPersCur_Input()
            {
                DeviceNo = "0000000000000000",
                Search = name,


            });

    string jsonString = JsonSerializer.Serialize(Obj);
     var serialaizer = new JsonSerializer();
     var jsonresult = JsonConvert.DeserializeObject(Person).tostring();
     var result = JsonConvert.DeserializeObject<Person>(jsonresult);
Posted
Updated 13-Oct-21 4:25am
Comments
Member 15329613 13-Oct-21 8:55am    
What was the error and what line of code caused the error?
mohamad_ali 13-Oct-21 9:02am    
in this cod i cant serialaize object: string jsonString = JsonSerializer.Serialize(Obj); the error is :
No overload for method 'Serialize' takes 1 arguments
Member 15329613 13-Oct-21 9:42am    
Do you understand what the error is telling you? The method Serialize requires either no parameters or more than 1 parameter.
mohamad_ali 13-Oct-21 10:03am    
i think the error its not accurate, u can check
Member 15329613 13-Oct-21 10:29am    
It is a compiler error, it is very accurate. But there are different packages that have a Serializer so you need to figure out which one you are using.

1 solution

If you're using Newtonsoft.Json, as the JsonConvert reference suggests, there is no static Serialize method on the JsonSerializer class. You would have to create an instance, and then call one of the instance Serialize methods, all of which require at least two parameters.

Alternatively, you could use the JsonConvert.SerializeObject static method, which only requires one parameter.

If you're using System.Text.Json, there is a static Serialize method. But again, all of the overloads require at least two parameters.
 
Share this answer
 

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