Results 1 to 4 of 4

Thread: Json parse error on <p>

  1. #1
    Join Date
    Jun 2010
    Posts
    45
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Json parse error on <p>

    Hello

    I am unable to to edit a json file i need to add some updates but i keep getting

    Code:
    Error: Parse error on line 8:
    ...           "text" : "
    
       company name -----------------------^ Expecting 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '[', got 'undefined'

    I am trying to add a paragraph with a section and when i put a <p> i get the error

    here is the code, please can you assist?


    Code:
    {
         "subSections":
         [
             {
               "title" : "The main website",
               "url" : "main-website",
               "linktitle" : "The main website",
               "text" : "<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>"
             }, {
               "title" : "The main reception",
               "url" : "main-reception",
               "linktitle" : "The main reception",
               "text" : "<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>"
             }, {
               "title" : "A heading",
               "url" : "a url heading",
               "linktitle" : "A heading",
               "text" : "<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</p><p>Our role involves ensuring that there is a warm friendly service for our patients and families when they come to GOSH.</p><p> Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.</p><p> It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>"
             }, {
               "title" : "A heading",
               "url" : "a url heading",
               "linktitle" : "A heading",
               "text" : "<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</p><p>Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.</p>"
             }, {
               "title" : "A heading",
               "url" : "a url heading",
               "linktitle" : "A heading",
               "text" : "<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</p>"      
             }, {
               "title" : "A heading",
               "url" : "a url heading",
               "linktitle" : "A heading",
               "text" : "<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</p><p>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</p>"
             }, {
               "title" : "A heading",
               "url" : "a url heading",
               "linktitle" : "A heading",
               "text" : "<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, </p>"
             }
         ]
     }

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    28,926
    Thanks
    43
    Thanked 3,192 Times in 3,155 Posts
    Blog Entries
    12

    Default

    Seems to work OK like so:

    Code:
    <script type="text/javascript">
    var j = JSON.parse('{\
         "subSections":\
         [\
             {\
               "title" : "The main website",\
               "url" : "main-website",\
               "linktitle" : "The main website",\
               "text" : "<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry\'s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>"\
             }, {\
               "title" : "The main reception",\
               "url" : "main-reception",\
               "linktitle" : "The main reception",\
               "text" : "<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry\'s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>"\
             }, {\
               "title" : "A heading",\
               "url" : "a url heading",\
               "linktitle" : "A heading",\
               "text" : "<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</p><p>Our role involves ensuring that there is a warm friendly service for our patients and families when they come to GOSH.</p><p> Lorem Ipsum has been the industry\'s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.</p><p> It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>"\
             }, {\
               "title" : "A heading",\
               "url" : "a url heading",\
               "linktitle" : "A heading",\
               "text" : "<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</p><p>Lorem Ipsum has been the industry\'s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.</p>"\
             }, {\
               "title" : "A heading",\
               "url" : "a url heading",\
               "linktitle" : "A heading",\
               "text" : "<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</p>"      \
             }, {\
               "title" : "A heading",\
               "url" : "a url heading",\
               "linktitle" : "A heading",\
               "text" : "<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</p><p>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</p>"\
             }, {\
               "title" : "A heading",\
               "url" : "a url heading",\
               "linktitle" : "A heading",\
               "text" : "<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry\'s standard dummy text ever since the 1500s, </p>"\
             }\
         ]\
     }');
    </script>
    Or, using the unaltered code from your post as an external file (json.json in this example), this also works OK:

    HTML Code:
    <!DOCTYPE html>
    <html>
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
    <script type="text/javascript">
    jQuery(function($){
    	$.getJSON('json.json', function(data){
    		$('#output').html(data.subSections[0].text);
    	});
    });
    </script>
    </head>
    <body>
    <div id="output"></div>
    </body>
    </html>
    Last edited by jscheuer1; 05-10-2013 at 09:50 AM. Reason: add external file method
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Jun 2010
    Posts
    45
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Hello John

    thanks for this, it does work.

    The error arises when i i put an extra <p> in one of the sections.

    I just need to update a few bits and it comes back with errors.

    C

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    28,926
    Thanks
    43
    Thanked 3,192 Times in 3,155 Posts
    Blog Entries
    12

    Default

    Show the actual contents of the json file that's giving you errors.

    Oh, and it might not be an added p. I found I could p all I wanted in the file as long as it was still valid JSON. One big NoNo would be using double quote marks (") within an entry.
    Last edited by jscheuer1; 05-11-2013 at 08:17 AM. Reason: usage, detail
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Similar Threads

  1. Resolved Parse error: syntax error unexpected 'echo'
    By Kage Kazumi in forum PHP
    Replies: 3
    Last Post: 10-21-2012, 08:19 PM
  2. Replies: 1
    Last Post: 01-28-2011, 02:39 AM
  3. Parse error: syntax error, unexpected $end
    By heavensgate15 in forum PHP
    Replies: 2
    Last Post: 02-24-2010, 05:38 AM
  4. Replies: 2
    Last Post: 02-12-2010, 08:53 AM
  5. Replies: 1
    Last Post: 04-26-2008, 11:22 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •