Getting data from local time countdown with json

Hello coders I have tried this method from yesterday but it is not working with this type of file in Json I have now.

This is what I have tried so far.
Tried with Dictionary Component
With this I am getting this error
Argument #1 (<script) to ‘com.google.appinventor.components.runtime.util.YailDictionary.walkKeyPath(com.google.appinventor.components.runtime.util.YailObject,java.util.List)’ has wrong type (java.lang.String) (java.lang.String cannot be cast to com.google.appinventor.components.runtime.util.YailObject)

And with this method, this is the error comes again

Argument #1 ( //############…) to ‘com.google.appinventor.components.runtime.util.YailDictionary.walkKeyPath(com.google.appinventor.components.runtime.util.YailObject,java.util.List)’ has wrong type (java.lang.String) (java.lang.String cannot be cast to com.google.appinventor.components.runtime.util.YailObject)

I then Tried with Json Component but there is no response from there


I have tried to change everything to see if it can work but nothing works

Here is the full Json Codes
:point_down: :point_down: :point_down: :point_down: :point_down:

<script type="text/javascript">
var CDown = function() {
	this.state=0;// if initialized
	this.counts=[];// array holding countdown date objects and id to print to {d:new Date(2021,11,18,18,54,36), id:"countbox1"}
	this.interval=null;// setInterval object
}

CDown.prototype = {
	init: function(){
		this.state=1;
		var self=this;
		this.interval=window.setInterval(function(){self.tick();}, 1000);
	},
	add: function(date,id){
		this.counts.push({d:date,id:id});
		this.tick();
		if(this.state==0) this.init();
	},
	expire: function(idxs){
		for(var x in idxs) {
			this.display(this.counts[idxs[x]], "Now!");
			this.counts.splice(idxs[x], 1);
		}
	},
	format: function(r){
		var pre='',post='',divide=', ',
			out="";
		if(r.d != 0){out += pre+r.d +" "+((r.d==1)?"day":"days")+post+divide;}
		if(r.h != 0){out += pre+r.h +" "+((r.h==1)?"hour":"hours")+post+divide;}
		out += pre+r.m +" "+((r.m==1)?"min":"mins")+post+divide;
		out += pre+r.s +" "+((r.s==1)?"sec":"secs")+post+divide;

		return out.substr(0,out.length-divide.length);
	},
	math: function(work){
		var	y=w=d=h=m=s=ms=0;

		ms=(""+((work%1000)+1000)).substr(1,3);
		work=Math.floor(work/1000);//kill the "milliseconds" so just secs

		y=Math.floor(work/31536000);//years (no leapyear support)
		w=Math.floor(work/604800);//weeks
		d=Math.floor(work/86400);//days
		work=work%86400;

		h=Math.floor(work/3600);//hours
		work=work%3600;

		m=Math.floor(work/60);//minutes
		work=work%60;

		s=Math.floor(work);//seconds

		return {y:y,w:w,d:d,h:h,m:m,s:s,ms:ms};
	},
	tick: function(){
		var now=(new Date()).getTime(),
			expired=[],cnt=0,amount=0;

		if(this.counts)
		for(var idx=0,n=this.counts.length; idx<n; ++idx){
			cnt=this.counts[idx];
			amount=cnt.d.getTime()-now;//calc milliseconds between dates

			// if time is already past
			if(amount<0){
				expired.push(idx);
			}
			// date is still good
			else{
				this.display(cnt, this.format(this.math(amount)));
			}
		}

		// deal with any expired
		if(expired.length>0) this.expire(expired);

		// if no active counts, stop updating
		if(this.counts.length==0) window.clearTimeout(this.interval);
		
	},
	display: function(cnt,msg){
		document.getElementById(cnt.id).innerHTML=msg;
	}
};

window.onload=function(){
	var cdown = new CDown();

	cdown.add(new Date(2021,9,17,15,00,56), "countbox1");
};
</script>
<div id="countbox1"></div>

Here is theindex.zip (1.2 KB)
:point_down: :point_down: :point_down:

  • you can run it to your browser and see how it works but I have failed to get the data

Please great ones may you help me on how to solve this
here is ancountdown.aia (27.8 KB)

I will really appreciate your help :pray: :pray: :pray:

The respone you are getting from web is not in json format so there is no way to work with dictionary blocks or with JSONTools extension

1 Like

Ok @dora_paz please how can we get the data despite of using Dictionary or JosnTool?
Please do something

You need to fix your Response Content.

This is not a Json.