I
I
Indiftech2021-01-13 01:31:45
JavaScript
Indiftech, 2021-01-13 01:31:45

How to write a JSON viewer web application in JS?

Haven't worked with JSON before and am just learning JS. You need to write an application for viewing JSON files in this form:
5ffe22a899de5024705032.jpeg

How to write similar web applications and what would you advise to use for implementation? It is necessary for JS

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
StasEx, 2021-01-13
@Indiftech

1. Create an empty array op type:

const InfoArr = [{keyName: "shopperEmail", valueType: 'array'}]

2. Loop recursively and determine the typeof of each element and write it into an empty array
const jsonObj = JSON.parse( yourJson )
const keysArr = Object.keys(jsonObj)
keyArr.forEach(key => infoArr.push({keyName: key, valueType: typeof jsonObj[key]}))

Only need to call recursion if typeof will be an object

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question