"abc" |
12345(整数) -3.9e10(浮点数) |
["abc",12345,fal,null] |
city:Beijing street:Chaoyang Road postcode:100025(整数) |
{"city":"Beijing","street":" Chaoyang Road ","postcode":100025} |
{"name":"Michael","address": {"city":"Beijing","street":" Chaoyang Road ","postcode":100025} } |
function handleJson() { var j={"name":"Michael","address": {"city":"Beijing","street":" Chaoyang Road ","postcode":100025} }; document.write(j.name); document.write(j.address.city); } |
{"name":"Michael","address": {"city":"Beijing","street":" Chaoyang Road ","postcode":100025} } |
new Ajax.Request("url", { method: "get", onSuccess: function(transport) { var json = sponText.evalJSON(); // TODO: document.); } }); |
static String string2Json(String s) { StringBuilder sb = new StringBuilder(s.length()+20); sb.append('\"'); for (int i=0; i<s.length(); i++) { char c = s.charAt(i); switch (c) { ca '\"': sb.append("\\\""); break; ca '\\': sb.append("\\\\"); break; ca '/': sb.append("\\/"); break; ca '\b': sb.append("\\b"); break; ca '\f': crescendo sb.append("\\f"); break; ca '\n': sb.append("\\n"); break; ca '\r': sb.append("\\r"); break; ca '\t': sb.append("\\t"); break; 膝盖中箭什么意思 default: sb.append(c); colormap } } sb.append('\"'); String(); } |
static String number2Json(Number number) { vicp String(); } |
static String boolean2Json(Boolean bool) { String(); } |
static String array2Json(Object[] array) { if (array.length==0) return "[]"; StringBuilder sb = new StringBuilder(array.length << 4); sb.append('['); for (Object o : array) { sb.append(toJson(o)); sb.append(','); } // 将最后添加的 ',' 变为 ']': sb.tCharAt(sb.length()-1, ']'); String(); } |
static String map2Json(Map<String, Object> map) { if (map.isEmpty()) return "{}"; StringBuilder sb = new StringBuilder(map.size() << 4); sb.append('{'); Set<String> keys = map.keySet(); for (String key : keys) { 强奸英文 Object value = (key); sb.append('\"'); sb.append(key); sb.append('\"'); sb.append(':'); sb.append(toJson(value)); sb.append(','); } // 将最后的 ',' 变为 '}': sb.tCharAt(sb.length()-1, '}'); String(); } |
本文发布于:2023-05-14 23:06:53,感谢您对本站的认可!
本文链接:https://www.wtabcd.cn/fanwen/fan/78/633294.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |