Quantcast
Channel: Daz Script Developer Discussion - Daz 3D Forums
Viewing all articles
Browse latest Browse all 1036

How to read a JSON file?

$
0
0

Hello,

I would like to read a Json file in Daz script,but here's some problem!!

when I  tap the oData in the script, I got the right value -0.1102951 in the first print  and 0 in the second print.

var oData = {
	"0Posx" : -0.1102951,
	"0Posy" : 107.0425,
	"0Posz" : -12.28755,
	"0Rotx" : 0.02013095,
	"0Roty" : -0.0003168428,
	"0Rotz" : -0.007650683,
	"0Sclx" : 0,
	"0Scly" : 0,
	"0Sclz" : 0
}		
var oSettings = new DzSettings();
print( oSettings.getFloatValue( "0Posx" ))
if( oSettings.fromString( JSON.stringify( oData ) ) ){
	print( oSettings.getFloatValue( "0Posx" ) );	
}
}

but when I tried to read the oData from json file, use getFloatValue, I got 0 in the first print whatever the true value is  and nothing returned  in the second print.

var file = new DzFile("C:/Users/momo/Desktop/pose.json");
var oData = file.read()
var oSettings = new DzSettings();
print( oSettings.getFloatValue( "0Posx" ))
if( oSettings.fromString( JSON.stringify( oData ) ) ){
	print( oSettings.getFloatValue( "0Posx" ) );	
}
}

I just want to read the value from a json file, please help!!

THANK YOU for replies!!

 


Viewing all articles
Browse latest Browse all 1036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>