用js显示json

时间:2014-06-03 10:00:09

标签: javascript jquery json

我需要一个项目来使用Json来显示带有一些特殊效果的图片墙。我决定使用Classier Json轻松创建类。我是json ad的新手,我不知道如何显示我的对象的内容。 这是我的代码:

// RANGES - MOSAIC

// Main class
Image=[
     'width','height','url','method',
     {
          width:'100px',
          height:'100px',
          getWidth:function(){return this.width},
          getHeight:function(){return this.height}
     }
].jsonClass();

Product=[
     'width','height','url','link','method',
     Image,
     {
        method:'product-pict',
        getMethod:function(){return this.method}
     }
].jsonClass()

Mood=[
     'width','height','url','method',
     Image,
     {
        method:'mood-pict',
        getMethod:function(){return this.method}
     }
].jsonClass()

Specific=[
     'width','height','url','method',
     Image,
     {
        method:'specific-pict',
        getMethod:function(){return this.method}
     }
].jsonClass()

//Produits
var P1=new Product('100px','100px','http://dev.playboy-fragrance.fr/sites/default/files/slide1_3.png');

//Mood
var M1=new Mood('100px','100px','http://../sites/default/files/mozaic_09.jpg');
var M2=new Mood('100px','100px','http://../sites/default/files/mozaic_11.jpg');
var M3=new Mood('100px','100px','http://../sites/default/files/mozaic_20.jpg');
var M4=new Mood('100px','100px','http://../sites/default/files/mozaic_12.jpg');
var M5=new Mood('100px','100px','http://../sites/default/files/mozaic_08.jpg');

//Specific
var S1=new Specific('100px','100px','http://../sites/default/files/mozaic_09.jpg');

console.log (P1);
console.log (M1);
console.log (S1);

返回

constr {width: "100px", height: "100px", url: "http://dev.playboy-fragrance.fr/sites/default/files/slide1_3.png", method: "product-pict", getMethod: function…}

如何用JS显示它? (Java或jQuery)

0 个答案:

没有答案