JSON到Prototype中的字符串 [英] JSON to string in Prototype

查看:119
本文介绍了JSON到Prototype中的字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个网站上的人似乎知道一切,所以我想我会问这个情况下:

The people on this website seem to know everything so I figured I would ask this just in case:

在原型中有一个方法/函数转换JSON对象到一个字符串,你可以存储在一个cookie?

Is there a method/function in prototype that converts a JSON object to a string that you can store in a cookie?

如果没有,..我将使用另一个外部库。

If not,..i'll just use another external library.

谢谢,
Andrww

Thanks, Andrww

推荐答案

当然有:原型JSON

var data = {name: 'Violet', occupation: 'character', age: 25 };
var myString = Object.toJSON(data);
// myString = '{"name": "Violet", "occupation": "character", "age": 25}'

然后将myString推送到您的Cookie

Then shove myString into your cookie

这篇关于JSON到Prototype中的字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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