Convert JSON generator objects to k/v pairs

by jakelauer

JavaScript

// 1. Copy your JSON string
// 2. Open the Chrome inspector
// 3. Run this: var json = [your JSON string]
// 4. Copy the code below and run that
// 5. Copy out the result
// 6. Beautify
// 7. Remove the "1:" from the beginning
// 8. Make the double {{ and }} at result into single { and }


var string = JSON.stringify(json);
var regex = /\{\"id\":(\d+)/g;
string = (string.replace(regex, "\"" + "$1" + "\"" + ":{"));
string = string.replace(/\[/g,"{").replace(/\]/g,"}").replace(/\{\,/g,"{")