Reputation: 196
may I not JSON.stringify() the output of ee.List() ?
var dates = ee.List(imageCollection.get('date_range'));
print('type: ', typeof(dates));
print('JSON.stringify: ', JSON.stringify(dates));
print('Date zero: ', dates.get(0));
print('type: ', typeof(dates.get(0)))
print('JSON.stringify: ', JSON.stringify(dates.get(0)))
and the console says:
type:
object
JSON.stringify:
{}
Date zero:
1365638400000
type:
object
JSON.stringify:
{}
my end-game is to interpret dates.get(0) as an integer....
Upvotes: 2
Views: 2421
Reputation: 893
Those are server objects. You have to request their value (with the synchronous getInfo()
or the asynchronous evaluate()
) to mix and match with a client-side function like JSON.stringify()
:
var dates = ee.List(imageCollection.get('date_range'));
print('type: ', typeof(dates));
print('JSON.stringify: ', JSON.stringify(dates.getInfo()));
print('Date zero: ', dates.get(0));
print('type: ', typeof(dates.get(0)))
print('JSON.stringify: ', JSON.stringify(dates.get(0).getInfo()))
Note that there's no need to stringify anything at this point. i.e. dates.get(0).getInfo()
is a Number
:
print('A number: ', Number(dates.get(0).getInfo()))
Upvotes: 2