Win a copy of Head First Android this week in the Android forum!

Marcus Vinícius

Greenhorn
+ Follow
since Mar 12, 2019
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
2
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Marcus Vinícius

Guys, I found the solution.

In this case, the JSON that I'm looking isn't an array, so I already started wrong.

After some search and help on the web, I finished it.



And this applies to any other String in JSON, I could make a .getString("stringname"); for each String in JSON with no worries !

Thank you again !
2 months ago

Roland Mueller wrote:

Marcus Vinícius wrote:Hello,

I'm making this APP for my company, but I've never used JSON with Java before, so I'm kinda lost here. After watching some tutorials, I made this function


That's my Log:
org.json.JSONException: Value GOOGLE BRASIL INTERNET LTDA at nome of type java.lang.String cannot be converted to JSONArray



The JSON string from the URL shows that you have an JSON object that is not an array. As immediate child there is the JSON value "nome" which has value "GOOGLE BRASIL INTERNET LTDA." and is definitely no array as the error message in the log says.

Probably, you should only retrieve the object with key "nome" and return it. following code is an untested guess:





Thanks for the reply, but how would I use it in the function ? I did some search and Json is a library from Java and when I tried to use it in Android it didn't work  
2 months ago
Hello,

I'm making this APP for my company, but I've never used JSON with Java before, so I'm kinda lost here. After watching some tutorials, I made this function


But the response from the URL that I get is a JSON with no name,

{
 "atividade_principal": [
   {
     "text": "Portais, provedores de conteúdo e outros serviços de informação na internet",
     "code": "63.19-4-00"
   }
 ],
 "data_situacao": "01/09/2004",
 "complemento": "ANDAR 17A20 TSUL 2 17A20",
 "tipo": "MATRIZ",
 "nome": "GOOGLE BRASIL INTERNET LTDA.", //I need this part

Can someone help me, please ? This array worked like a charm, how to get "nome" from this JSON ?



If anyone needs the whole JSON: https://www.receitaws.com.br/v1/cnpj/06990590000123

That's my Log:
org.json.JSONException: Value GOOGLE BRASIL INTERNET LTDA at nome of type java.lang.String cannot be converted to JSONArray

I thank you for the help, my native forums aren't helping me
2 months ago
Hi guys, I need some help here with NetBeans. I have a project that uses MySQL and NetBeans, but everytime I try to connect the DB, it shows me an error message. Can someone help me, please ?
P.S: The names are in portuguese, but the error is in english.
2 years ago
Thanks for the welcome and for the help ! Yeah... I translated it to english, the code is actually in portuguese and didn't realize that it was in upper. But about the rest, thanks, it helped me a lot !
2 years ago
JSF
Hey guys, I have this college project that is to calculate your BMI. I started learning JSF now, so I'm a newbie in the language.

The problem is in the index page you put your birthdate and in the next page it shows your age.

Index.xhtml



Calculate.xhtml



I found some functions getAge() in google, but with static values and this project works with input values. That's why I can't understand.
2 years ago
JSF