• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 316
  • Last Modified:

breaking a JSON file into two files

hi guys

I have a layout file in JSON which is 700 lines


layout_project.JSON

  "trade:Manager":{
         "id":"trade:Manager",
         "name":"Manager",
         "render":[
            "Text"  
         ],
         "renderAs":"Text",        
         "key":"TradeId",        
         "value":"",        
         "visible":true,
         "events":[

         ],
         "req":"/app/tradeApp.do",
         "reqType":"json",
         "reqMethod":"GET",
         "width":150,
         "height":20,
         "inc":[

         ],
       
      },
  "trade:Client":{
         "id":"trade:Client",
         "name":"Client",
         "render":[
            "Text"  
         ],
         "renderAs":"Text",        
         "key":"TradeId",        
         "value":"",        
         "visible":true,
         "events":[

         ],
         "req":"/app/tradeApp.do?client="Paula",
         "reqType":"json",
         "reqMethod":"GET",
         "width":150,
         "height":20,
         "inc":[

         ],
       
      },
....and so on


My requirment is
i want to break the one json file into two JSON files each containing 350 lines

layout_project.JSON  contains layout_project1.JSON (350 lines) + layout_project2.JSON (350 lines)

Is that possible?

thanks
0
royjayd
Asked:
royjayd
  • 2
1 Solution
 
leakim971PluritechnicianCommented:
if the your main/top object in an array of json element you may split it :

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/Array.html#slice()

var jsonObject1:Array = jsonObject.slice(0,parseInt(jsonObject.length/2));
var jsonObject2:Array = jsonObject.slice(parseInt(jsonObject.length/2));
0
 
royjaydAuthor Commented:
thanks
but i think you misunderstood the question
I dont want anything in actionscript . i just have a JSON file with 700 lines. For better readability
i want to split the large JSON file into two smaller JSON files..something like
layout_project.JSON
{
layout_project1.JSON
layout_project2.JSON
}

layout_project1.JSON
{
"trade:Manager":{
         "id":"trade:Manager",
         "name":"Manager",
         "render":[
            "Text"  
         ],
         "renderAs":"Text",        
         "key":"TradeId",        
         "value":"",        
         "visible":true,
         "events":[

         ],
         "req":"/app/tradeApp.do",
         "reqType":"json",
         "reqMethod":"GET",
         "width":150,
         "height":20,
         "inc":[

         ],
       
      }
}

and

layout_project2.JSON
{
"trade:Client":{
         "id":"trade:Client",
         "name":"Client",
         "render":[
            "Text"  
         ],
         "renderAs":"Text",        
         "key":"TradeId",        
         "value":"",        
         "visible":true,
         "events":[

         ],
         "req":"/app/tradeApp.do?client="Paula",
         "reqType":"json",
         "reqMethod":"GET",
         "width":150,
         "height":20,
         "inc":[

         ],
       
      }
}


Is something like that possible?

thx

0
 
leakim971PluritechnicianCommented:
yes of course,
check the validity with this tools : http://jsonlint.com/
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now