利用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 ...
随机推荐
- dotnetConf
https://channel9.msdn.com/Events/dotnetConf/2016 https://channel9.msdn.com/Events/dotnetConf/2016?so ...
- Measuring PostgreSQL Checkpoint Statistics
Checkpoints can be a major drag on write-heavy PostgreSQL installations. The first step toward ident ...
- MSSQL中建立分区表(转载备忘)
转载自CSDN地址:http://bbs.csdn.net/topics/330087045 SQL Server 2005 分区表实践——建立分区表(partition table) 问题:有一个订 ...
- no ocijdbc11 in java.library.path linux
no ocijdbc11 in java.library.path linux vi /etc/profile export ORACLE_HOME=/oracle/database/oracle/p ...
- 如何修改Oracle字符集
一.什么是Oracle字符集 Oracle字符集是一个字节数据的解释的符号集合,有大小之分,有相互的包容关系.ORACLE 支持国家语言的体系结构允许你使用本地化语言来存储,处理,检索数据.它使数据库 ...
- Angular学习(3)- 双向梆定
示例代码: <!DOCTYPE html> <html ng-app="MyApp"> <head> <title>Study 3& ...
- nova分析(5)—— nova-conductor
nova-conductor是nova-compute之上的一个服务,这个服务比较简单,主要封装了DB访问和动态迁移相关的代码.转来一篇文章看看它是如何工作的. 更新记录:1. 2013.4.19 ...
- c# string 数组转 list
string str = "1,11,121,131"; var arr = str.Split(','); List<string> list = new List& ...
- 剑指offer系列36----二叉搜索树的第k个节点
[题目]给定一颗二叉搜索树,请找出其中的第k大的结点. * 例如, 5 * / \ * 3 7 * / \ / \ * 2 4 6 8 中,按结点数值大小顺序第三个结点的值为4. 中序遍历:2 3 4 ...
- Python 共享和上传函数模块到PyPI
1. register account by brower on https://pypi.python.org/pypi/ 2. register your moudle "nester& ...