The core logic is in the Flatten method, which recursively traverses the JSON. It handles JSON objects by appending property names to the key and JSON arrays by appending the index. When it reaches a simple value (like a string, number, or boolean), it adds the generated key and the value to the dictionary.
Flatten
You can run this code to see how the sample nested JSON is transformed into a flat key-value pair format. You can easily adapt this by replacing the sample nestedJson string with your own JSON data.
nestedJson
There is also Logic created to convert the Flatten Json in to an Array as required.