awsdocs/aws-glue-developer-guide

AWS Glue Relationalize does not preserver the original JSON order

turjachaudhuri opened this issue · 2 comments

Input JSON to glue relationalize =>

{
	"player": {
		"username": "user1",
		"characteristics": {
			"race": "Human",
			"class": "Warlock",
			"subclass": "Dawnblade",
			"power": 300,
			"playercountry": "USA"
		},
		"arsenal": {
			"kinetic": {
				"name": "Sweet Business",
				"type": "Auto Rifle",
				"power": 300,
				"element": "Kinetic"
			},
			"energy": {
				"name": "MIDA Mini-Tool",
				"type": "Submachine Gun",
				"power": 300,
				"element": "Solar"
			},
			"power": {
				"name": "Play of the Game",
				"type": "Grenade Launcher",
				"power": 300,
				"element": "Arc"
			}
		},
		"armor": {
			"head": "Eye of Another World",
			"arms": "Philomath Gloves",
			"chest": "Philomath Robes",
			"leg": "Philomath Boots",
			"classitem": "Philomath Bond"
		},
		"location": {
			"map": "Titan",
			"waypoint": "The Rig"
		}
	}
}

Output from Glue =>

{
	"player.arsenal.energy.power": 300,
	"player.arsenal.power.power": 300,
	"player.arsenal.kinetic.type": "Auto Rifle",
	"player.armor.arms": "Philomath Gloves",
	"player.username": "user1",
	"player.arsenal.kinetic.name": "Sweet Business",
	"player.arsenal.kinetic.power": 300,
	"player.characteristics.power": 300,
	"player.armor.chest": "Philomath Robes",
	"player.arsenal.power.type": "Grenade Launcher",
	"player.arsenal.energy.type": "Submachine Gun",
	"player.characteristics.class": "Warlock",
	"player.characteristics.subclass": "Dawnblade",
	"player.armor.head": "Eye of Another World",
	"player.arsenal.power.element": "Arc",
	"player.characteristics.race": "Human",
	"player.location.waypoint": "The Rig",
	"player.armor.classitem": "Philomath Bond",
	"player.arsenal.power.name": "Play of the Game",
	"player.arsenal.energy.element": "Solar",
	"player.arsenal.energy.name": "MIDA Mini-Tool",
	"player.armor.leg": "Philomath Boots",
	"player.location.map": "Titan",
	"player.characteristics.playercountry": "USA",
	"player.arsenal.kinetic.element": "Kinetic"
}

As you can see the original order is not being preserved .
How to fix this?

JSON objects are like Dictionaries/Maps, which are unordered. As such - you shouldn't assume any order of the entries.

Do you have some logic later down the relies on it or do you want the order for readability?

Closed due to inactivity.