๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

JSON2

[iOS] Objective-C NSMutableDictionary ๋ฅผ json ํ˜•ํƒœ๋กœ ๋ณ€ํ™˜ iOS (Objective-C) ์—์„œ JSON ํ˜•ํƒœ๋กœ http ํ†ต์‹ ์„ ํ•˜๊ธฐ ์œ„ํ•ด json ํ˜•ํƒœ๋กœ ๋ณ€ํ™˜์„ ํ•˜๋Š” ์ฝ”๋“œ์ด๋‹ค. NSMutableDictionary ํ˜•ํƒœ์˜ ๋ฐ์ดํ„ฐ๋ฅผ NSJSONSerialization ์„ ์ด์šฉํ•ด NSData ๋กœ ๋ณ€ํ™˜ํ•œ ํ›„, ๋‹ค์‹œ NSString ์œผ๋กœ ๋ณ€ํ™˜ํ•œ๋‹ค. NSMutableDictionary *retDic = [[NSMutableDictionary alloc]init]; [retDic setValue:๊ฐ’1 forKey:@"ํ‚ค1"]; [retDic setValue:๊ฐ’2 forKey:@"ํ‚ค2"]; NSData *requestData = [NSJSONSerialization dataWithJSONObject:retDic options:0 error:nil]; NSString *req.. 2021. 10. 6.
javascript ์—์„œ ajax๋ฅผ ์ด์šฉํ•ด ์—ฌ๋Ÿฌ ๊ฐœ์˜ ๋ฐ์ดํ„ฐ๋ฅผ json format์œผ๋กœ ํ•˜๋‚˜๋กœ ๋ฌถ์–ด์„œ ์ธ์ฝ”๋”ฉํ•ด ์„œ๋ฒ„๋กœ ์ „์†กํ•˜๋Š” ๋ฐฉ๋ฒ• javascript ์—์„œ ajax๋ฅผ ์ด์šฉํ•ด ์—ฌ๋Ÿฌ ๊ฐœ์˜ ๋ฐ์ดํ„ฐ๋ฅผ json format์œผ๋กœ ํ•˜๋‚˜๋กœ ๋ฌถ์–ด์„œ ์ธ์ฝ”๋”ฉํ•ด ์„œ๋ฒ„๋กœ ์ „์†กํ•˜๋Š” ๋ฐฉ๋ฒ• (๊ตฌ๊ตฌ์ ˆ์ ˆ) ๋ณธ์ธ์˜ ๊ธฐ์–ต์šฉ ๊ฒŒ์‹œ๊ธ€์ž„. ใ…‡ใ…‡ ---- ํด๋ผ ---- javascript // ์„œ๋ฒ„๋กœ ๋ณด๋‚ผ ๊ฐ’ var data1 = "hello"; var data2 = "world"; // json format ๋งŒ๋“ค์–ด key : value ์Œ์œผ๋กœ ๋งŒ๋“ค์–ด ์ฃผ๊ธฐ var jsonData = new Object(); jsonData.key1 = data1; jsonData.key2 = data2; // ์œ„์—์„œ ๋งŒ๋“  json format์„ ๋ฌธ์ž์—ดํ™” var sendData = JSON.stringify(jsonData); // ์„œ๋ฒ„๋กœ ์ „๋‹ฌ $.ajax({ url:'๊ฐ’์„ ์ „๋‹ฌ ๋ฐ›์„ ์„œ๋ฒ„์˜.. 2020. 11. 5.