核心报告Api返回JSON + django

时间:2022-09-01 15:21:45

I am querying the core reporting api to get unique visitors.

我正在查询核心报告api以获得独特的访问者。

It returns a Json object that looks like this

它返回一个看起来像这样的Json对象

{u'kind': u'analytics#gaData', u'rows': [[u'11', u'2011', u'New Visitor', u'24961'],...

{u'kind':u'analytics#gaData',u'rows':[[u'11',u'2011',u'New Visitor',u'24961'],...

what is the u that is in the prefix and how can i get rid of it.

前缀中的u是什么,我怎么能摆脱它。

Further when i do a console.log on the json object it outputs

此外,当我在json对象上执行console.log时,它会输出

{& # 3 9 ;raw& # 3 9;: {u & # 3 9 ;kind & # 3 9;: u & # 3 9;analytics#gaData', u'rows': [[u'11',... (Added space to show that its printing the ascii value)

{ 9; raw 9;:{u 9; kind 9;:u 9; analytics#gaData',u'rows':[[u'11',. ..(添加空间以显示其打印ascii值)

Any insights?

1 个解决方案

#1


1  

u means it is in unicode format.

你的意思是它是unicode格式。

since most django use unicode. you can convert it into strings by str() method

因为大多数django使用unicode。你可以通过str()方法将它转换成字符串

#1


1  

u means it is in unicode format.

你的意思是它是unicode格式。

since most django use unicode. you can convert it into strings by str() method

因为大多数django使用unicode。你可以通过str()方法将它转换成字符串