JSON.parse: expected double-quoted property name (var json = JSON.parse( xhr.responseText );)

15,654

I think this is caused by extra comma at line 8.

"materials": [ { 
    "DbgColor" : 15658734, 
    "DbgIndex" : 0, 
    "DbgName" : "dummy", 
    "colorDiffuse" : [ 1, 0, 0 ], 
} ],

To spot issues like that validators may help, for example, http://jsonlint.com.

Share:
15,654
Author by

Adnan Mateen

Updated on June 05, 2022

Comments

  • Adnan Mateen over 1 year

    https://www.dropbox.com/s/h59v7elqn05t7lc/bag.js

    the following code gives the link to the json file is given

    SyntaxError: JSON.parse: expected double-quoted property name
    

    Javascript:

    var init = function () {
        var canv = document.getElementsByTagName("canvas")[0];
        var w = canv.clientWidth;
        var h = canv.clientHeight;
        var renderer = new THREE.WebGLRenderer({
            canvas: canv
        });
        renderer.setSize(w, h);
        var scene = new THREE.Scene();
        var camera = new THREE.PerspectiveCamera(
            15, // Field of view
        w / h, // Aspect ratio
        0.1, // Near
        10000 // Far
        );
        camera.position.set(-1, 1, 15);
        scene.add(camera);
        var light = new THREE.PointLight(0xFFFFDD);
        light.position.set(-15, 10, 15);
        scene.add(light);
        var ambient = new THREE.AmbientLight(0x999999);
        scene.add(ambient);
        var loader = new THREE.JSONLoader();
        var onGeometry = function (geom) {
            var mesh = new THREE.Mesh(geom, new THREE.MeshFaceMaterial());
            scene.add(mesh);
        };
        loader.load("vwbug.js", onGeometry);
        var render = function () {
            renderer.render(scene, camera);
        };
        setInterval(render, 10);
    };
    window.onload = init;
    window.onresize = init;
    
  • mrdoob
    mrdoob over 10 years
    Line 22 also has an extra comma.
  • Adnan Mateen over 10 years
    ok fixed it but its saying .. TypeError: material is undefined... but the materials are defined :\
  • sbat over 10 years
    "ok fixed it but its saying .. TypeError: material is undefined... but the materials are define" - for this issue you may want to create separate question for others to comment (unless you can debug it on your end). This seems to be three.js related, and I am not that good at it. :)