Parsing a TexturePacker JSON file

When I use texture packer to publish a texture atlas of for “Unity3d”, it creates a txt file with the following JSON format:

{
	"frames": {
		"frame-abc.png":
		{
			"frame": {"x":41,"y":2,"w":256,"h":256},
			"rotated": false,
			"trimmed": false,
			"spriteSourceSize": {"x":0,"y":0,"w":256,"h":256},
			"sourceSize": {"w":256,"h":256}
		},
		"someframe":
		{
			"frame": {"x":2,"y":2,"w":37,"h":382},
			"rotated": false,
			"trimmed": false,
			"spriteSourceSize": {"x":0,"y":0,"w":37,"h":382},
			"sourceSize": {"w":37,"h":382}
		}
	}
}

My question is, how can I parse this to create a simple class so I can easily access the uv coordinates for each frame:

public class FrameAtlas{
    Frame[] frames;
}

public class Frame {
    private string name;
    private Rect rect;
}

Use LitJSON: http://lbv.github.io/litjson/

Or use JSONObject: http://wiki.unity3d.com/index.php/JSONObject

Or, since you’re providing the JSON, there aren’t any security issues with just using eval(), but it’s much slower than LitJSON.

Or, if you can get Texture Packer to export to XML instead, you can use XmlSerializer to load it.

If you really need access to the UV coordinates one of the JSON readers is the best solution. See above.

However if you intend to create sprites from the data the way easier solution is to use Unity’s Texture2D / Sprite classes with a sprite sheet. This already handles the complete drawing and also allows you to directly use your sprites in the editor.

There’s a unity plugin that can directly parse sprite sheet data.