在html页面中,我可以获取以下任意一个json对象。为了知道接收到的是哪个json对象,我需要检查这些json对象的深度。有人能建议一种在PHP中获取json对象深度的方法吗?
下面列出了两种json格式:
{
"Category": {
"name" : "Camera",
"productDetails" : {
"imageUrl" : "/assets/images/product1.png",
"productName" : "GH700 Digital Camera",
"originalPrice" : 20000,
"discountPrice" : 16000,
"discount" : 20
}
}
并且
{
"city" : {
"cityname": "ABC",
"Category": {
"name" : "Camera",
"productDetails" : {
"imageUrl" : "/assets/images/product1.png",
"productName" : "GH700 Digital Camera",
"originalPrice" : 20000,
"discountPrice" : 16000,
"discount" : 20
}
}
}