selwin / python-user-agents

A Python library that provides an easy way to identify devices like mobile phones, tablets and their capabilities by parsing (browser) user agent strings.
MIT License
1.44k stars 197 forks source link

Add ability to dump json #15

Open hakib opened 9 years ago

hakib commented 9 years ago

Dumping the object to JSON could be great. As far as i know namedtuples are not serializeable so i use jsno.dumps(ua.browser.__dict__). Plus, Exposing the ua_parser parsed dict as a property as well.

The true added value here is the is_mobile/pc/tablet/touch properties.

vnnw commented 8 years ago

I think it will be easily done by import ujson, then you just do: ujson.dumps(parse(ua_agent_string))