Sugar.json.JsonObject.getKeys: java.lang.ClassCastException

On a Android target with sugar.jar from Sugar develop tree,
I have a cast error:

java.lang.ClassCastException: java.lang.Object[] cannot be cast to java.lang.String[]

Full strack trace:

at sugar.json.JsonObject.getKeys()
at sugar.json.JsonSerializer.VisitObject()
at sugar.json.JsonSerializer.Visit()
at sugar.json.JsonSerializer.Serialize()
at sugar.json.JsonObject.ToJson()

when trying to print a Sugar.Json.JsonObject with toJson() or toString() methods:

writeLn( jsonObject.ToJson() ) or writeLn( jsonObject.ToString() )`

in a HttpContentResponseBlock:

let jsonCallback: HttpContentResponseBlock<Sugar.Json.JsonDocument!>! = { response in 
			if response.Success {
				
				
				// Json Object Response
				let jsonObject:Sugar.Json.JsonObject = response.Content.RootObject;
				
				self.logger.debug( jsonObject.ToJson() );
				success( cacheObject.ToJson() );
				
			}
			else {
				error(response.Exception);
			}
		}
		Http.ExecuteRequestAsJson( Url(url), jsonCallback)

The same code runs without error in iOS target.

Thanks, logged as bugs://74587

1 Like

(edited)
If can help it seems that the bug is in the super class JsonNode object since I get the same stracktrace for:

                           var jsonString = "{}";
			do {
				let jsonItem:Sugar.Json.JsonNode = try jsonObject.Item["artists"];
				jsonString=jsonItem.ToString();
			} catch error {
			}

Fixed as for: How to execute a HttpRequest of type HttpRequestMode.Post.

1 Like

bugs://74587 got closed with status fixed.