'2018/11/06'에 해당되는 글 2건

  1. 2018.11.06 okhttp3와 moshi 개발이 편하다..
  2. 2018.11.06 python으로 해결하는 JSONP 파싱 예시




okhttp3와 moshi만 있으면 자바/스칼라 http 통신이 완전 편해진다.. 



okhttp3와 moshi는 json serialization/deserialization 개발 공부를 크게 낮춘다.





https://github.com/square/okhttp/wiki/Recipes


https://github.com/square/moshi


Posted by '김용환'
,




python으로 해결하는 JSONP 파싱 예시이다.



>>> import requests

>>> url = '...'

>>> jsonp = requests.get(url % 1000)

>>> jsonp.content

b'callback({"status":{

...

})' 

>>> import json

>>> pure_json = jsonp.text[jsonp.text.index('(') + 1 : jsonp.text.rindex(')')]

>>> dealers = json.loads(pure_json)

>>> dealers.keys()

dict_keys(['status'])

>>> dealers['count']

10 



Posted by '김용환'
,