Answered by:
How To Craete ASP.NET Web API to Return JSON

Question
-
User-341459723 posted
Can u help me for this application
There is a shopping mall with 8 vehicle gates (8 entrance and 8 exit) .
## Inputs
* `Plate number` - A string of Alpha Numerics.
* `Entrance Timestamp` - A Unix timestamp.
* `INOUTAgentMACID` - A string of integers.
* `OUTAgentMACID` - A string of Integers.
## OutputYour ASP demo App should focus on loading these inputs, processing them according to the above mentioned
The output should be API which focusses around each Platenumber. For each Plate number, we want to know the answers for the following questions.
- Activity Log JSON. [Mentioned below]
2. Session Log JSON. [Mentioned below]
3. Analytics.JSON. [Mentioned below]
The format of the JSON output file should be similar to this structure:
```
<%-- Activity.json --%>
{
"102123": {
"Type": "IN",
"OUTAgentMACID": "00-14-22-01-23-45",
"PlateNumber": {
"Image": "/poll/data/date0/img.png",
"Number": "ABC1234",
"TimeStamp": 5901291
}
},
"102124": {
"Type": "OUT",
"OUTAgentMACID": "00-14-22-01-31-45",
"PlateNumber": {
"Image": "/poll/data/date0/img1.png",
"Number": "ABC1234",
"TimeStamp": 5991291
}
},
"102125": {
"Type": "IN",
"INAgentMACID": "00-14-22-01-63-45",
"PlateNumber": {
"Image": "/poll/data/date1/img2.png",
"Number": "ABC1234",
"TimeStamp": 6001239
}
}
}
In the above Json the auto inceremented value 102123 is the sessionID
<%-- Session.json --%>
{
{
"SessionID":102123,
"Platenumber":"ABCD1234",
"Intime":53808092,
"Outtime": NA,
"INAgentMACID":"00-24-22-01-23-45",
"OUTAgentMACID":"00-64-22-01-23-45",
"Status": "ongoing"
},
{
"SessionID":102222,
"Platenumber":"ABFD1234",
"Intime":53808032,
"Outtime": 53808032,
"INAgentMACID":"00-24-32-01-23-45",
"OUTAgentMACID":"00-64-27-01-23-45",
"Status": "Ended"
}
}
<%-- Analytics.json --%>
{
"Date":"DDMMYYY",
"TotalSessions":"209",
"OngoingSessions":"59",
"FinishedSessions":"150"
}
- **Logging** - Your code should include logs, logging to `STDOUT`. Logging is essential in debugging a system running in production. Logs at the `INFO` level should include decisions your program is making, while the `DEBUG` level can be anything that adds more context to the decision.
There following requirements need to be meet:
Generate a random `Activity.json` with 100 entries and produce the `session.json` and `Analytics.json`
Your submission must run on Windows.
Monday, March 25, 2019 7:47 AM - Activity Log JSON. [Mentioned below]
Answers
-
User36583972 posted
Hi NabilMosali,Form your description, I suggest you can refer the following articles.
JSON and XML Serialization in ASP.NET Web API:
https://docs.microsoft.com/en-us/aspnet/web-api/overview/formats-and-model-binding/json-and-xml-serializationUsing an alternate JSON Serializer in ASP.NET Web API
https://weblog.west-wind.com/posts/2012/Mar/09/Using-an-alternate-JSON-Serializer-in-ASPNET-Web-APIThen, try to develop the ASP.NET Web Application on your side.
Best Regards
Yong Lu
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, March 26, 2019 7:49 AM
All replies
-
User36583972 posted
Hi NabilMosali,Form your description, I suggest you can refer the following articles.
JSON and XML Serialization in ASP.NET Web API:
https://docs.microsoft.com/en-us/aspnet/web-api/overview/formats-and-model-binding/json-and-xml-serializationUsing an alternate JSON Serializer in ASP.NET Web API
https://weblog.west-wind.com/posts/2012/Mar/09/Using-an-alternate-JSON-Serializer-in-ASPNET-Web-APIThen, try to develop the ASP.NET Web Application on your side.
Best Regards
Yong Lu
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, March 26, 2019 7:49 AM -
User-694834778 posted
Don't use your browser to test your API.
Instead, try to use an HTTP client that allows you to specify your requests, such as CURL, or even Fiddler.
The problem with this issue is in the client, not in the API. The web API behaves correctly, according to the browser's request.
Movers and Packers in Dubai | Movers in Dubai | Movers and Packers in Sharjah | Movers in Sharjah
Thursday, March 28, 2019 12:16 PM -
User-341459723 posted
Thank u so much for help me :) Yohann Lu
I read this article Using an alternate JSON Serializer in ASP.NET Web API ==> this is article amzing and helpful for me :)
Monday, April 1, 2019 7:02 AM -
Monday, April 1, 2019 7:11 AM
-
User438705957 posted
By default, Web API supplies both JSON and XML media formatters.
Which one is used to serialise the response is based on what is sent in the Accept header from the Ajax call.Wednesday, April 3, 2019 4:14 AM