利用js将 json对象在textarea中赋值与展示
明明很简单的东西,可惜网上一大堆废话。在此记录,转需。
jsonStr = JSON.stringify(jsondata,null,);
example:
<!doctype html>
<!-- paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/ -->
<!--[if lt IE 7 ]>
<html class="no-js ie6" lang="en"> <![endif]-->
<!--[if IE 7 ]>
<html class="no-js ie7" lang="en"> <![endif]-->
<!--[if IE 8 ]>
<html class="no-js ie8" lang="en"> <![endif]-->
<!--[if (gte IE 9)|!(IE)]><!-->
<html class="no-js" lang="en"> <!--<![endif]-->
<head>
<meta charset="utf-8"> <!-- Always force latest IE rendering engine (even in intranet) & Chrome Frame
Remove this if you use the .htaccess -->
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <title>flow CURD测试</title> <!-- Mobile viewport optimized: j.mp/bplateviewport -->
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- CSS: implied media="all" -->
<load href="/api/Application/Habo_v2/View/Index/style.css"/>
<load href="__PUBLIC__/css/bootstrap.min.css" />
<load href="__PUBLIC__/js/jquery.js" />
<load href="__PUBLIC__/js/bootstrap.min.js" /> <!-- All JavaScript at the bottom, except for Modernizr which enables HTML5 elements & feature detects --> </head> <body class="home"> <div class="container">
<header>
<h3>flow CURD 接口测试</h3> </header> <form>
<div class="form-group">
<label for="flowid">FlowId:</label>
<input id="flowid" type="text" class="form-control" placeholder="input flowid here">
</div>
<div class="form-group">
<label for="flowdata">Example jsondata</label>
<textarea id="flowdata" class="form-control bg-muted code" rows="18" placeholder="Input flow json data here"></textarea>
</div>
<div class="form-group row">
<button id="createflow" type="button" class="btn btn-primary col-md-2 col-md-offset-2">新建</button>
<button id="updateflow" type="button" class="btn btn-primary col-md-2">修改</button>
<button id="searchflow" type="button" class="btn btn-primary col-md-2">查找</button>
<button id="deleteflow" type="button" class="btn btn-primary col-md-2">删除</button>
</div>
</form> <div class="clear"></div>
</div> <footer>
<div id="footer">
Copyright ©
<script type="text/javascript">
d = new Date();
document.write(d.getFullYear());
</script>
<span>Habo, Inc. All rights reserved.</span><br/>
Generated by <a href="http://Habo.oa.com">Habo</a>.
</div>
</footer>
</div> <!--! end of #container --> <script>
$(function(){
$("#searchflow").click(function(){
var flow_id = $("#flowid").val();
var param = {
'flow_id' : flow_id
};
console.log("flowID",flow_id);
$.getJSON("/api/index.php/Habo_v2/DiyApi/getFlowData",data=param, function(jsondata){
jsonStr = JSON.stringify(jsondata,null,4);
$("#flowdata").val(jsonStr);
console.log("flowData: ",jsondata);
});
});
})
</script> </body>
</html>
利用js将 json对象在textarea中赋值与展示的更多相关文章
- js 替换json对象中的键名
js 替换json对象中的键名 CreateTime--2018年3月30日15:38:50 Author:Marydon 情景描述: 有个json数组,现在需要将json对象中的key替换掉,值 ...
- 类对象传输到jsp页面。需要转换为js的json对象时,这么做。
场景:要从一个列表中选择信息,填写入父页面的表单中,但是字段非常多... 后台查询,得到结果,放在列表中. 效果:点击选择产品.. 弹出页面:点击后面的选择产品 选择产品后:信息自动填充.. 实现:点 ...
- Js拼Json对象
我们通常会拼字符串,但是拼字符串的话,遇见占位符会出错. 下面分享一个拼js拼json对象的方法: var jsonArr = []; $ ...
- js遍历json对象
原生js遍历json对象 遍历json对象: 无规律: <script> var json = [ {dd:'SB',AA:'东东',re1:123}, {cccc:'dd',lk:'1q ...
- JAVA利用反射映射JSON对象为JavaBean
关于将JSONObject转换为JavaBean,其实在JSONObject中有对于的toBean()方法来处理,还可以根据给定的JsonConfig来处理一些相应的要求,比如过滤指定的属性 //返回 ...
- js 将json对象转成字符串
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- javascript、js操作json对象和字符串互相转换方法
相信前端的同学们对json并不陌生,接触过很多.但是很少人知道json的全称是什么,哈哈,我也是查资料知道的.(JSON JavaScript Object Notation是一种轻量级的数据交换格式 ...
- js:JSON对象与JSON字符串转换
JSON(JavaScript Object Notation) 是一种轻量级的数据交换格式,采用完全独立于语言的文本格式,是理想的数据交换格式. 同时,JSON是 JavaScript 原生格式,这 ...
- 【Js】JSON对象、JSON字符的使用总结
JSON对象 / JSON字符串区别 抛出一个最常见的疑问:什么是“JSON对象”,什么是“JSON字符串”,它俩的区别是什么? 废话不多说,直接上代码. 1.JSON对象: // javascrip ...
随机推荐
- 使用swiper和吸顶效果代码
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8&quo ...
- kindEditor使用注意事项
5,关于数据库和上传本地图片问题 Kindeditor对于上传的图片神马的会默认保存在attached文件夹中,至于数据库字段中存储的只是图片的地址,所以将内容读取出来的时候,只要读取数据库字段中的内 ...
- C#, float.ToString()的一个坑
下面代码的输出竟然是2.0: float a=1.95f;Debug.Log(a.ToString("0.0")); 如果想截取一位小数,可以: float a=1.95f; fl ...
- OpenJudge计算概论-发票统计
/*====================================================================== 发票统计 总时间限制: 1000ms 内存限制: 65 ...
- python 字典访问的三种方法
定义字典 dic = {'a':"hello",'b':"how",'c':"you"} 方法一: for key in dic: prin ...
- mybatis migrate常用指令
0.制定db和配置文件 --path=xxx --env=dev 1.初始化Migrations工作目录 migrate init 2.创建数据库变更 migrate new "liyq a ...
- nginx http跳转到https
server { listen 80; server_name www.888.com; location / { #index.html放在虚拟主机监听的根目录下 root /usr/local/n ...
- linux下安装svn
linux下SVN服务器如何搭建和使用 | 浏览:12117 | 更新:2013-09-18 14:28 | 标签:linux linux下SVN服务器如何搭建和使用?说到SVN服务器,想必大家都知道 ...
- eclipse中web工程新建jsp文件报错:The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path
web工程中新建jsp文件提示:The superclass "javax.servlet.http.HttpServlet" was not found on the Java ...
- ajax简单案例:字符串返回类型
小知识点: implode("^",$v) 拼数组为字符串, split/explode("|") 拆字符串为数组; "你好"-> ...