Click here to Skip to main content
15,885,953 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
A web API need to be created to read from a json file and write output to stream.

What I have tried:

[ApiController]
public class ValuesController : ControllerBase
{
// GET api/values
[HttpGet]
public object Get()
{
string allText = System.IO.File.ReadAllText("/data.json");
object jsonObject = JsonConvert.DeserializeObject(allText);
return jsonObject;
}
}

this only outputs json file..how will i do data streaming.
Posted
Updated 5-Mar-19 2:45am
Comments
[no name] 5-Mar-19 4:01am    
What are you streaming where?
[no name] 5-Mar-19 5:13am    
i have a large json file .reading it in one stretch is time consuming. so the same json should be output using data streaming.
Wastedtalent 5-Mar-19 4:21am    
Something like this?

https://www.morgantechspace.com/2013/08/convert-object-to-byte-array-and-vice.html
[no name] 5-Mar-19 4:22am    
i have a large json file.i need to stream this json data to output.
Wastedtalent 5-Mar-19 4:26am    
In what format? What are you attempting to do with the data at the other end?

1 solution

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