2

I've got a nested json object. For the sake of simplicity:

data = {'key1': 1, 'key2': 2, 'key3': {'nestedKey1': 3, 'nestedKey2': 4}}

A real object is bigger but the point is that it's a nested one. Values may be strings, numbers or other objects. Now I need to get an excel table that (for this specific json would look like this):

|----------------------------------------
| key1 | key2 |           key3          |
|      |      |--------------------------
|      |      | nestedKey1 | nestedKey2 |
|----------------------------------------
|  1   |  2   |     3      |      4     |
|----------------------------------------

Other formats are also acceptable. But this one is most preferable. How do I do that?

2 Answers 2

0

You can convert online(don't know the size limit they allow)

Although it is not exactly in the same format you expect but it is very much similar, you can do little bit of modification from the output you get here. Here is a sample screenshot of the output I got when I inserted your json. enter image description here

Stackoverflow

If you want to write a Service on your own then you can refer to this question on SOF. It is something similar to what you want and it is written in JavaScript.

JQuery

Here is a JQuery script on this page for converting JSON to excel.

Working Stackblitz

Sign up to request clarification or add additional context in comments.

4 Comments

No, I can't do that, I need to write a service that does just that. I tried using 'xlsx' but I can't figure out how to make it write the table in the right format
You need to write it in which language. I mean which tools and framework are you working on ?
Ah, sorry I forgot to mention it. The framework is angular, the language is typescript.
@GoBear Ihave updated my answer have a look at the stackblitz example. I think that should be sufficient for your requirement
0

I have written a python package that you can use to convert complex json into excel. https://github.com/akritianand/JsonToExcel

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.