• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 311
  • 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

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

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