c#- Json as stream to excel

259 Views Asked by At

I have .json files stored in AWS S3 bucket. I use the function OpenStreamAsyncto get a specified file and I want to read it and arrange the items according to the way I expect them to be in the .json file but into excel (I use EEPlus).

What is the best practice to do so?

1

There are 1 best solutions below

0
Micah Armantrout On BEST ANSWER
{ "name":"John", "age":30, "car":null }

1) create a class that matches your JSON you could use http://json2csharp.com/

public class RootObject
{
    public string name { get; set; }
    public int age { get; set; }
    public object car { get; set; }
}

2) use Json.NET to deserialize

Install Package

PM> Install-Package Newtonsoft.Json


Code to serialize JSON
var group2 = JObject.Parse(yourjson).ToObject<RootObject>();
  1. Create your EEPlus document with your objects