0

in my app i recevie char sequence thats from sql something like this:

"{"1":{"from":"540","to":"1020"},"2":{"from":"540","to":"1020"},"3":{"from":"540","to":"1020"},"4":{"from":"540","to":"1020"},"5":{"from":"540","to":"1020"},"6":{"from":"540","to":"1020"},"7":{"from":"540","to":"1020"}}" 

This is full week, day by day and minutes since midnight. I have idea how to use it but i don't know right now how to crop it on sense strings which should be looks like:

String monday_open = 540; String monday_close = 1020; 

and same to the end of the week Maybe somebody know easy way to crop this sequence?

1 Answer 1

1

this

"{"1":{"from":"540","to":"1020"},"2":{"from":"540","to":"1020"},"3":{"from":"540","to":"1020"},"4":{"from":"540","to":"1020"},"5":{"from":"540","to":"1020"},"6":{"from":"540","to":"1020"},"7":{"from":"540","to":"1020"}}" 

is a json Text

my json String

{ "coord": { "lon": 51.42, "lat": 35.69 }, "weather": [ { "id": 721, "main": "Haze", "description": "haze", "icon": "50n" } ], "base": "cmc stations", "main": { "temp": 298.45, "pressure": 1016, "humidity": 39, "temp_min": 298.15, "temp_max": 299.15 }, "wind": { "speed": 2.1, "deg": 240 }, "clouds": { "all": 40 }, "dt": 1439151053, "sys": { "type": 1, "id": 7032, "message": 0.0034, "country": "IR", "sunrise": 1439084924, "sunset": 1439134215 }, "id": 112931, "name": "Tehran", "cod": 200 } 

and i parse it with method blew:

private void jsonRead(String file) throws JSONException { JSONObject root=new JSONObject(file); JSONArray jsonArray = root.optJSONArray("weather"); JSONObject jo2=root.optJSONObject("main"); for(int i=0; i < jsonArray.length(); i++) { JSONObject jsonObject = jsonArray.getJSONObject(i); dama.setText(jsonObject.getString("description")); } rotobat.setText(jo2.getString("humidity")); } 
Sign up to request clarification or add additional context in comments.

1 Comment

do you have same example?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.