javascript - Convert json string objects to json Array -


  • i need format json string in such manner nodes having name "children" should array type.
  • at places have children array type not @ places.
  • if array type no need operation on that.

input:

 "foldchildren": "false",                             "branchcolor": "#000000",                             "children": [                                 {                                     "id": "3f67cbab-ff5a-4f61-b1ef-d551271e8af2",                                     "parentid": "211c838e-3e2d-4919-ab09-dd7f8a901b97",                                     "text": {                                         "caption": "f",                                         "font": {                                             "style": "normal",                                             "weight": "normal",                                             "decoration": "none",                                             "size": "15",                                             "color": "#000000"                                         }                                     },                                     "offset": {                                         "x": "30",                                         "y": "93"                                     },                                     "foldchildren": "false",                                     "branchcolor": "#000000",                                     "children": {                                         "id": "2ecaecb6-d55c-4203-bace-f14e276700af",                                         "parentid": "3f67cbab-ff5a-4f61-b1ef-d551271e8af2",                                         "text": {                                             "caption": "x",                                             "font": {                                                 "style": "normal",                                                 "weight": "normal",                                                 "decoration": "none",                                                 "size": "15",                                                 "color": "#000000"                                             }                                         },                                         "offset": {                                             "x": "122",                                             "y": "114"                                         },                                         "foldchildren": "false",                                         "branchcolor": "#000000",                                         "children": ""                                     }                                 }, 

expected output:

 "foldchildren": "false",                             "branchcolor": "#000000",                             "children": [                                 {                                     "id": "3f67cbab-ff5a-4f61-b1ef-d551271e8af2",                                     "parentid": "211c838e-3e2d-4919-ab09-dd7f8a901b97",                                     "text": {                                         "caption": "f",                                         "font": {                                             "style": "normal",                                             "weight": "normal",                                             "decoration": "none",                                             "size": "15",                                             "color": "#000000"                                         }                                     },                                     "offset": {                                         "x": "30",                                         "y": "93"                                     },                                     "foldchildren": "false",                                     "branchcolor": "#000000",                                     "children": [{                                         "id": "2ecaecb6-d55c-4203-bace-f14e276700af",                                         "parentid": "3f67cbab-ff5a-4f61-b1ef-d551271e8af2",                                         "text": {                                             "caption": "x",                                             "font": {                                                 "style": "normal",                                                 "weight": "normal",                                                 "decoration": "none",                                                 "size": "15",                                                 "color": "#000000"                                             }                                         },                                         "offset": {                                             "x": "122",                                             "y": "114"                                         },                                         "foldchildren": "false",                                         "branchcolor": "#000000",                                         "children": []                                     }]                                 }, 


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - Bypass Geo Redirect for specific directories -

php - .htaccess mod_rewrite for dynamic url which has domain names -