নেস্টেড JSON অবজেক্ট অ্যাক্সেস করা নেস্টেড অ্যারে অ্যাক্সেস করার মতোই। নেস্টেড অবজেক্ট হলো যেই অবজেক্টগুলো অন্য একটি অবজেক্টের ভিতরে থাকে।
নিচের উদাহরণে 'vehicles' একটি অবজেক্ট যা মূল অবজেক্ট 'person'-এর ভিতরে রয়েছে। ডট নোটেশন ব্যবহার করে নেস্টেড অবজেক্টের প্রোপার্টি (car) অ্যাক্সেস করা হয়েছে।
উদাহরণ-১
<html> <body> <script> var person = { "name":"Ram", "age":27, "vehicles": { "car":"limousine", "bike":"ktm-duke", "plane":"lufthansa" } } document.write("Mr Ram has a car called" + " " + person.vehicles.car); </script> </body> </html>আউটপুট
Mr Ram has a car called limousine
উদাহরণ-২
নিচের উদাহরণে, "air-lines" নামক একটি অবজেক্ট ডাবলি নেস্টেড (নেস্টেড অবজেক্টের ভিতর নেস্টেড)। সেটির প্রোপার্টি (lufthansa) ডট নোটেশন দিয়ে অ্যাক্সেস করা হয়েছে।
<html> <body> <script> var person = { "name":"Ram", "age":27, "vehicles": { "car":"limousine", "bike":"ktm-duke", "airlines":{ "lufthansa" : "Air123", "British airways" : "Brt707" } } } document.write("Mr Ram travels by plane called" + " " + person.vehicles.airlines.lufthanza); </script> </body> </html>আউটপুট
Mr Ram travels by plane called Air123