2d array and Parse function return

yoyopi
2012-09-07
2013-04-22
  • yoyopi

    yoyopi - 2012-09-07

    Hello,

    I've got a Json file formatted like this :

    {
        "FIRST_ITEM":[
            {"line1": "Hello"                                           },
            {"line2": "world"                                           }
        ],
        "SECOND_ITEM":[
            { "line1" : "This is"                                       },
            { "line2" : "my first"                                      },
            { "line3":"Json ccp"                                        },
            { "line4":"project"                                         }
        ],
    

    When I'm trying to call Parse function it return a false value.

    I feel that this function was not designed to work with this file structure. Is anyone have the same problem?

    Thanks for you answers!

     
  • Brad

    Brad - 2012-09-07

    Hi yoypi.

    What you have there isn't propertly formatted JSON. You shouldn't have commas after } and ]. Commas are used to separate items within {} and .

    Also it looks like you are missing the closing } for the first {

     
  • yoyopi

    yoyopi - 2012-09-07

    I think my paste snipet was not correctly formatted. My JSON file is formatted like this (I hope it works!)

    {
     "FIRST_ITEM":[ 
                     {"line1": "Hello" }, 
                     {"line2": "world" }
     ], 
    "SECOND_ITEM":[ 
                    { "line1" : "This is" }, 
                    { "line2" : "my first" },
                    { "line3":"Json ccp" }, 
                    { "line4":"project" }
     ]
    
     
  • Brad

    Brad - 2012-09-07

    Get rid of the commas. Try this:

    {
     "FIRST_ITEM":[ 
                     {"line1": "Hello" }
                     {"line2": "world" }
     ]
    "SECOND_ITEM":[ 
                    { "line1" : "This is" }
                    { "line2" : "my first" }
                    { "line3":"Json ccp" }
                    { "line4":"project" }
     ]
    }
    

    JSON syntax is defined at www.json.org

     
  • Brad

    Brad - 2012-09-07

    Sorry, ignore my previous reply. The commas are needed, but you are missing a '}' at the end. Try this:

    {
     "FIRST_ITEM":[ 
                     {"line1": "Hello" }, 
                     {"line2": "world" }
     ], 
    "SECOND_ITEM":[ 
                    { "line1" : "This is" }, 
                    { "line2" : "my first" },
                    { "line3":"Json ccp" }, 
                    { "line4":"project" }
     ]
    }
    
     
  • yoyopi

    yoyopi - 2012-09-11

    Sorry, I've forgot to put the } at the end of the sample file but in my "real" file I've put it!

    I found the problem in my file a comma whas missing!! Thanks for your help.

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks