我想找到一个像下面这样带括号的甲酸盐。
它需要以“ {id: ”开头,以“ } ”结尾,
并且id值为AZ。就这样。
我被内括号弄糊涂了...
下面是一个样品甲酸盐。
{
id: "A",
cid: "6331411109881515776",
latlng: {
lat: 37.492488999999999,
lng: 127.014357
},
image: "http://maps.gstatic.com/intl/ko_kr/mapfiles/markers2/markerA.png",
sprite: {
width: 20,
height: 34,
top: 0,
image: "http://maps.gstatic.com/mapfiles/markers2/red_markers_A_J2.png"
},
icon_id: "A",
drg: true,
laddr: "강남대성학원, 서울특별시 서초구 서초1동 1657-7",
geocode: "CQISkUJWkUyzFQkXPAId1RWSByEAD3Pz27DdVym31_joa6F8NTEAD3Pz27DdVw",
sxti: "강남대성학원",
sxst: "서초1동",
sxsn: "1657-7",
sxct: "서울특별시",
sxpr: "",
sxpo: "137-071",
sxcn: "KR",
sxph: "+8225817217",
name: "강남대성학원",
ss: {
edit: true,
detailseditable: true,
deleted: false,
rapenabled: true,
mmenabled: true
},
elms: [
4,
1,
6,
1,
10,
2,
12,
1,
9,
1,
5,
2,
11
]
},
谢谢你的帮助~~
** * * 2012/07/19 编辑* ** * *
我的代码是
NSError *error = nil;
NSString *urlString = [NSString stringWithFormat:@"http://maps.google.co.kr?q=%@&output=json",
[address stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
//#define NSKoreanEncoding 0x80000422
NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:urlString] options:kNilOptions error:&error];
NSString *dataString = [[NSString alloc] initWithData:data encoding:NSKoreanEncoding];
//remove the while(1); from data
dataString = [dataString substringFromIndex:9];
// Create SBJSON object to parse JSON
SBJsonParser *parser = [[SBJsonParser alloc] init];
NSMutableDictionary *dict = [parser objectWithString:dataString error:&error];
NSLog(@"ERROR: %@", error);
NSLog(@"dict: %@", dict);
NSLog(@"dataString: %@",dataString);
//Samples can get result
NSString *jsonStr = @"{\"name\":\"jia\",\"age\":\"24\"}";
NSString *jsonStr2 = @"[\"1\",\"2\"]";
SBJsonParser *jsonParser = [[SBJsonParser alloc] init];
dict = [jsonParser objectWithString:jsonStr];
NSLog(@"%@",dict);
NSMutableArray *arr = [jsonParser objectWithString:jsonStr2];
NSLog(@"%@",arr);
因为真正的JSON对象是一个“key”=“value”的格式,我不能用它们来做字典……此外,还有一种方法可以改变格式……
下面是几行与我的目标相同的 Java 代码。
//remove while(1);
String jsonString = sb.toString().substring(9);
Log.d(TAG_SERVER, jsonString);
JSONObject jj = new JSONObject(jsonString);
//get "overlays" object
JSONObject overlays = jj.getJSONObject("overlays");
//get "markers" object
JSONArray markers = overlays.getJSONArray("markers");
我的目标是获得标记。它们包含谷歌地图的完整搜索结果。
如果有人知道怎么做,请告诉我~~