User:Jackmcbarn/Parsoid params format

Given this wikitext:

Current format: {	"1": { "wt": "red" }, "2": { "wt": "yellow" }, "3": { "wt": "blue" }, "4": { "wt": "4" }, "orange": { "wt": "1" }, "green": { "wt": "2" }, "violet": { "wt": "3" } } This loses information and breaks the switch, since order isn't maintained.

New proposed format: [	{ "value": { "wt": "red" } }, { "name": { "wt": "orange" }, "value": { "wt": "1" } }, { "value": { "wt": "yellow" } }, { "name": { "wt": "green" }, "value": { "wt": "2" } }, { "value": { "wt": "blue" } }, { "name": { "wt": "violet" }, "value": { "wt": "3" } }, { "value": { "wt": "4" } } ] This encodes all of the information the old format does, but also maintains order.

Making it easier on consumers: [	{ "effectivekey": "1", "value": { "wt": "red" } }, { "effectivekey": "orange", "name": { "wt": "orange" }, "value": { "wt": "1" } }, { "effectivekey": "2", "value": { "wt": "yellow" } }, { "effectivekey": "green", "name": { "wt": "green" }, "value": { "wt": "2" } }, { "effectivekey": "3", "value": { "wt": "blue" } }, { "effectivekey": "violet", "name": { "wt": "violet" }, "value": { "wt": "3" } }, { "effectivekey": "4", "value": { "wt": "4" } } ] If a parameter were a duplicate, effectivekey wouldn't be set for it.

Alternatively, have two structures: [	{ "value": { "wt": "red" } }, { "name": { "wt": "orange" }, "value": { "wt": "1" } }, { "value": { "wt": "yellow" } }, { "name": { "wt": "green" }, "value": { "wt": "2" } }, { "value": { "wt": "blue" } }, { "name": { "wt": "violet" }, "value": { "wt": "3" } }, { "value": { "wt": "4" } } ]

{	"1": { 1 },	"2": { 3 },	"3": { 5 },	"4": { 7 },	"orange": { 2 }, "green": { 4 }, "violet": { 6 } } Here, the second structure maps cleaned-up names to indices in the first.