All Questions
Tagged with json.net asp.net-web-api
591
questions
0
votes
0
answers
19
views
How do I use ValidationAttribute or IModelBinder to ensure that an enum property exists in the JSON body and has a valid value?
Given a model that looks like this:
public enum Types
{
Emergency,
Notice,
Event
}
public class Message
{
public Types Type { get; set; }
public string Title { get; set; }
}
And ...
0
votes
0
answers
38
views
Serializing table data with reference entity with NewtonSoft.Json in ASP.NET 4.8 Web API
I am working on an ASP.NET Web API which returns table data from database using linq2SQL.
I need to include reference entity data to response, till only one level.
If reference table next referencing ...
2
votes
1
answer
227
views
Forcing SnakeCaseNamingStrategy doesn't work in ASP.NET MVC
I'm trying to force both serialization and deserialization to use SnakeCaseNamingStrategy but no luck.
Here is what I have used in Global.asax.cs:
protected void Application_Start() {
...
0
votes
1
answer
60
views
Getting error, while trying consume API and display the contents in gridview of ASP.NET Webform
Error: Target type System.Collections.IEnumerable is not a value type or a non-abstract class. Parameter name: targetType.
I was trying to consume Web API endpoint with below gridview and C# function....
1
vote
1
answer
346
views
Can I redefine output formatter for one controller method in Net Core 6?
All my method in Backend API working fine and return correct JSON by the same way
Return OK(obj)
Return Unauthorized()
Return StatusCode(StatusCodes.Status500InternalServerError, obj)
But in one ...
1
vote
1
answer
566
views
JsonIgnore attribute is not working in asp.net
My model is
using Newtonsoft.Json;
...
public class User
{
public int Id { get; set; }
public string Login { get; set; }
public string Password { get; set; }
...
1
vote
1
answer
109
views
How to deserialize array of guid ids received from cognito attribute
I have custom attribute in cognito used for mapping third party claims.
After mapping is completed(on user login) I receive values as string in this format
[bf5ad010-8961-49d7-b068-87f23026f49d,
...
0
votes
1
answer
234
views
Apply IsoDateTimeConverter to Incoming Request
I created a Web API in .Net, I added the global settings below:
var jsonSettings = new JsonSerializerSettings();
jsonSettings .Converters.Add(new IsoDateTimeConverter() { DateTimeFormat = "yyyy-...
0
votes
1
answer
148
views
Customize object serialization to Json in c#
I am making an asp.net core web api and i want to return Ok(JsonList) in a specific format
I have a list of the following object:
public class obj
{
string schoolName;
int studentscount;
int ...
0
votes
4
answers
642
views
How to read the JSON values from the unstructured data in c#?
{
"id": "zd_tags",
"value": [
"bp_ticket;pazure_server"
]
},
{
"id": "itd_priority_1",
"value": 900
},
{
"id&...
-1
votes
1
answer
423
views
Request Model is null when I post it to API
I'm facing a problem doing post requests via .Net6 Web API. I'm a bit confused about it.
Since .Net6 we prefer to use System.Text.Json in place of Newtonsoft.Json
I have one Bool property in Request ...
0
votes
1
answer
434
views
Json Deserialization in an ASP.NET not working properly
I have an API that returns the following response as string
[
{
"id": "62a9f8f90346133662624bd3",
"referenceID": "test1",
"additionalInfoList&...
-2
votes
1
answer
486
views
Deserialize json into csharp object errors - Could not cast or convert from System.String to ProjectName.Models.CarsModel
I'm stuck with a tricky json.
trying to deserialize below web api json into c# object.
Seems like it has no key, only the below value.
["toyota","bmw","nissan","gmc&...
0
votes
1
answer
2k
views
From API response Cannot deserialize the current JSON object
I am getting this error when trying to deserialize data. the details are given below.
ALso the screenshot of the running App in which i debugged the app and can see the data from my api response.
My ...
0
votes
1
answer
2k
views
Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value - ASP.NET
How to properly deserialize POST method "Update" while developing Telegram bot in ASP.NET Core Web API by using Telegram.Bot package?
I used DeserializeObject(string) method to do so, but it ...