Book Image

Maya Programming with Python Cookbook

By : Adrian Herbez
Book Image

Maya Programming with Python Cookbook

By: Adrian Herbez

Overview of this book

Maya is a 3D graphics and animation software, used to develop interactive 3D applications and games with stupendous visual effects. The Maya Programming with Python Cookbook is all about creating fast, powerful automation systems with minimum coding using Maya Python. With the help of insightful and essential recipes, this book will help you improve your modelling skills. Expand your development options and overcome scripting problems encountered whilst developing code in Maya. Right from the beginning, get solutions to complex development concerns faced when implementing as parts of build.
Table of Contents (17 chapters)
Maya Programming with Python Cookbook
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

Working with JSON data


In this example, we'll look at the other format you're likely to want to use—JSON. JSON can model data just as well as XML, but is considerably more compact. As such, it has been growing in popularity in recent years and has all but replaced XML for many tasks.

Getting ready

Once again, you'll want to make sure that you have a file being served by a server that you have access to, but this time you'll want to make sure that it's JSON data. Once again, we'll create some number of cubes and spheres, but this time, we'll specify the data as an array of JSON objects.

The full listing for the example document is as follows:

[
    {"type": "cube", "size": 3, "x": 0, "y": 2, "z": 3},
    {"type": "sphere", "size": 1, "x": 0, "y": 0, "z": 0}
]

The square brackets indicate an array, and the curly brackets indicate an object. Within an object, there can be any number of named values. Arrays and objects can also be nested, allowing us to have an array of objects, as we do here. For...