<p>The error <code>not well-formed        male.json</code> doesn't appear to have anything to do with the code you've posted. I don't see any references to a JSON file called <code>male.json</code>.</p>

<p>If this file is in your code somewhere, the error is telling you the problem. It is malformed. Paste the contents of the file into an online validation tool such as <a href="http://jsonlint.com/" rel="nofollow noreferrer">JSONLint</a>. It will tell you what is making it malformed.</p>

<p>Also, you're passing JSON into <code>ObjectLoader.load</code> but you don't do anything with the results. Instead try this:</p>

<pre><code>var loader = new THREE.ObjectLoader();
loader.load('somemodel.json', function (object) {
    scene.add(object);
});
</code></pre>

<p>Check out <a href="https://threejs.org/docs/#api/en/loaders/ObjectLoader" rel="nofollow noreferrer">the documentation</a> for more information.</p>

CC BY-SA 4.0
2016-04-16T23:14:54.010Z
2020-01-06T03:51:50.203Z
2020-01-06T03:51:50.203Z
Exide
<p>I need to load a model "somemodel.json" into my "movie.js".Can someone tell me where i am going wrong.I followed the steps given <a href="http://threejs.org/docs/#Reference/Loaders/ObjectLoader" rel="nofollow">here</a>.</p>

<p><strong>index.html</strong></p>

<pre class="lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
&lt;html&gt;
    &lt;head&gt;
         &lt;meta charset=utf-8&gt;
         &lt;title&gt;Test&lt;/title&gt;
         &lt;style&gt;
            body { margin: 0; }
            canvas { width: 100%; height: 100% }
         &lt;/style&gt;
    &lt;/head&gt;
    &lt;body&gt;
        &lt;script src="three.min.js"&gt;&lt;/script&gt;
        &lt;script src="ObjectLoader.js"&gt;&lt;/script&gt;
        &lt;script src="movie.js"&gt;&lt;/script&gt;
    &lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p><strong>movie.js</strong></p>

<pre class="lang-js prettyprint-override"><code>var camera;
var scene;
var renderer;
var loader;

frame();
animate();

function frame() {

scene = new THREE.Scene();
camera = new THREE.PerspectiveCamera( 45, window.innerWidth /     window.innerHeight, 0.1, 1000);
camera.position.y = 0;
camera.position.z = 10;
camera.rotation.x = 0;

var loader = new THREE.ObjectLoader();
loader.load(
'somemodel.json',
function () {
    var geometry = new THREE.SphereGeometry(3,32,32);
    var material = new THREE.MeshBasicMaterial();
    var object = new THREE.Mesh( geometry, material );
    scene.add( object );
}
);

renderer = new THREE.WebGLRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
document.body.appendChild( renderer.domElement );
render();
}

function animate() {
render();
requestAnimationFrame( animate );
}

function render() {
renderer.render( scene, camera );
}
</code></pre>

<p>Or can your give an example with a sample model ?</p>

<p>When i run my file it raises an error in the console saying <code>not well-formed        male.json</code></p>

<webgl>
How to load a model in .json in three.js
Sri Sanketh Uppalapati
# How to load a model in .json in three.js

(Asked by: username_0 on 2016-04-16)

I need to load a model "somemodel.json" into my "movie.js".Can someone tell me where i am going wrong.I followed the steps given here.
index.html


    
         
         Test
         
    
    
        
        
        
    


movie.js
var camera;
var scene;
var renderer;
var loader;

frame();
animate();

function frame() {

scene = new THREE.Scene();
camera = new THREE.PerspectiveCamera( 45, window.innerWidth /     window.innerHeight, 0.1, 1000);
camera.position.y = 0;
camera.position.z = 10;
camera.rotation.x = 0;

var loader = new THREE.ObjectLoader();
loader.load(
'somemodel.json',
function () {
    var geometry = new THREE.SphereGeometry(3,32,32);
    var material = new THREE.MeshBasicMaterial();
    var object = new THREE.Mesh( geometry, material );
    scene.add( object );
}
);

renderer = new THREE.WebGLRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
document.body.appendChild( renderer.domElement );
render();
}

function animate() {
render();
requestAnimationFrame( animate );
}

function render() {
renderer.render( scene, camera );
}

Or can your give an example with a sample model ?
When i run my file it raises an error in the console saying not well-formed        male.json

**Tags:** webgl

---

## 1 answers

### Answer by username_1 on 2016-04-16. Score: 2

The error not well-formed        male.json doesn't appear to have anything to do with the code you've posted. I don't see any references to a JSON file called male.json.
If this file is in your code somewhere, the error is telling you the problem. It is malformed. Paste the contents of the file into an online validation tool such as JSONLint. It will tell you what is making it malformed.
Also, you're passing JSON into ObjectLoader.load but you don't do anything with the results. Instead try this:
var loader = new THREE.ObjectLoader();
loader.load('somemodel.json', function (object) {
    scene.add(object);
});

Check out the documentation for more information.


---

