原型具有hash.inspect()方法. jQuery世界中的等效功能是什么? [英] Prototype has hash.inspect() method. What is the equivalent in jQuery world?

查看:108
本文介绍了原型具有hash.inspect()方法. jQuery世界中的等效功能是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用jQuery.我正在处理JSON对象和对象,一次又一次,我需要查看数据.我确实警报(数据),但没有任何用处.

I am using jQuery. I am dealing with JSON object and time and again I need to look at the data. I do alert(data) and I get nothing useful.

在原型世界中,他们使用了非常有用的检查方法. 原型中的检查方法

In the Prototype world they have inspect method which is highly useful. inspect method in Prototype

我正在寻找jQuery中的等效方法.我看了看API,找不到任何东西.我敢肯定有人会开发一些插件来解决这个问题.

I am looking for equivalent method in jQuery. I looked at the API and couldn't find anything. I am sure someone would have developed some plugin to solve this problem.

推荐答案

我使用 http可获得最佳结果://www.JSON.org/json2.js .正如文档所说:

I have the best result with http://www.JSON.org/json2.js. As the docs say:

    JSON.stringify(value, replacer, space)
        value       any JavaScript value, usually an object or array.

        replacer    an optional parameter that determines how object
                    values are stringified for objects. It can be a
                    function or an array of strings.

        space       an optional parameter that specifies the indentation
                    of nested structures. If it is omitted, the text will
                    be packed without extra whitespace. If it is a number,
                    it will specify the number of spaces to indent at each
                    level. If it is a string (such as '\t' or ' '),
                    it contains the characters used to indent at each level.

只需包含该库并调用alert(JSON.stringify(data))即可清楚地看到您的对象.

Just include the library and call alert(JSON.stringify(data)) to see a legible representation of your object.

这篇关于原型具有hash.inspect()方法. jQuery世界中的等效功能是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆