开发者

Extracting only a specified part of a string in Android

Let's say I have a string :

{"id":"123","xCoord":"01.234567","yCoord":"89.012345","etc.":"etcetc"}

I want to extract only the xCoord part - the number 01.234567 and put it into a string array String[] xCoords = {};

I cannot use the public String substring (int st开发者_开发问答art, int end) function because in future the id will eventually grow up and I don't have a firm index to use.

What would you suggest me - is there any way of extracting only the symbols after "xCoord":" and before ","y...


The best (and most reliable) option would be to convert your string (which is valid JSON) into an object and reference it that way.

Convert JSON String to Java Object or HashMap

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜