package com.fylibs.utils
{
/**
* @author:Frost.Yen
* @E-mail:871979853@qq.com
* @create:2015-12-25 下午3:34:28
*
*/
public class JSON2XML
{
public function JSON2XML()
{
}
/**
* 将object对象转换成xml,主要目的是将json格式的数据转换成xml
* @param obj 要转换的对象
* @param node 节点
* return XML
*/
public static function obj2xml(obj:Object, node:String):XML
{
var xml:XML=new XML(<{node}></{node}>);
switch(typeof(obj))
{
case "int":
case "uint":
case "number":
case "string":
case "boolean":
return new XML(<{node}>{obj.toString()}</{node}>);
}
for(var str:String in obj)
{
switch(typeof(obj[str]))
{
case "int":
case "uint":
case "number":
case "string":
case "boolean":
xml.appendChild(<{str}>{obj[str]}</{str}>)
break;
case "array":
case "object":
if(obj[str].length){
for each(var item:Object in obj[str])
{
xml.appendChild(obj2xml(item, str));
}
}else{
if(isNaN(Number(str))){//如果不是数字
xml.appendChild(obj2xml(obj[str], str));
}else{
xml.appendChild(obj2xml(obj[str], node));
} }
break;
}
}
return xml;
}
}
}

[ActionScript 3.0] AS 实现JSON转换为XML的更多相关文章

  1. 字符串json转换为xml xml转换json

    原文:字符串json转换为xml xml转换json // To convert an XML node contained in string xml into a JSON string XmlD ...

  2. 在.NET2.0中解析Json和Xml

    在.NET解析json有很多方法,这里介绍最简单也用的最多的一种. 一.添加引用 解析Json,先下载开源控件 Newtonsoft.Json.dll 下载地址:http://files.cnblog ...

  3. JaxbUtil转json转XML工具类

    json转换为XML工具类 package com.cxf.value; import org.springframework.util.StringUtils; import javax.xml.b ...

  4. js压缩xml字符串,将xml字符串转换为xml对象,将xml对象转换为json对象

    /** * 压缩xml字符串 */ function compressXmlStr(str){ var prefix, suffix; var i = str.indexOf("\r&quo ...

  5. [ActionScript 3.0] as3处理xml的功能和遍历节点

    as3比as2处理xml的功能增强了N倍,获取或遍历节点非常之方便,类似于json对像的处理方式. XML 的一个强大功能是它能够通过文本字符的线性字符串提供复杂的嵌套数据.将数据加载到 XML 对象 ...

  6. 都 2021 年了,竟然有人搞大数据时忽略 JSON 而去研究用 C# 把 XML 转换为 XML 的技术

    在大数据项目开发过程中,ETL(Extract-Transform-Load)是必不可少.即便目前 JSON 非常流行,开发人员也有必定会有对远古系统的挑战,而 XML 格式的数据源作为经典存在浑身上 ...

  7. [ActionScript 3.0] AS3.0 生成xml方法之一

    var type:Array = ["type0", "type1", "type2"]; var property:Array = [[& ...

  8. [ActionScript 3.0] 根据xml属性查找相应xml节点,递归函数。

    import flash.net.URLLoader; import flash.net.URLRequest; import flash.events.Event; var xml:XML; var ...

  9. Dreamer 3.0 支持json、xml、文件上传

    自己写的框架,功能类似Struts2.x 下载地址:http://pan.baidu.com/share/link?shareid=3273223286&uk=470382596 新增功能: ...

随机推荐

  1. 001. 使用ssh连接不上centos 6.5的解决方法及其解决中文乱码

    1. 使用ssh连接不上centos 6.5的解决方法: 错误显示: Connecting to 192.168.1.106:22... Could not connect to '192.168.1 ...

  2. linux服务之snmp

    背景信息 http://datatracker.ietf.org/doc/rfc1213/ http://oid-info.com/get/1.3.6.1 http://oid-info.com/ge ...

  3. maxscript, 数组和字符串下标是从1开始的

    maxscript中数组和字符串下标是从1开始的.

  4. Nginx实现静态资源的缓存

    1.1   需求 1.对静态文件进行缓存:html,js,css,png,gif,jpg,jpeg,bmp,swf. 2.对符合url规则的请求进行缓存. 3.针对某个url进行清除缓存. 1.1   ...

  5. HiveQ与传统SQL差异

    1.   hive内连接支持什么格式? • SQL中对两表内联可以写成:        select * from dual a,dual b where a.key = b.key; 或者: SEL ...

  6. SIlverlight外包公司【技术展望】— Silverlight5.1.2最新版本发布,Silverlight 的更新从未停止。

    微软发布新版Silverlight 5, 版本号5.1.20913.0 大家可以到微软网站去下载最新版本网址是 http://www.microsoft.com/getsilverlight/get- ...

  7. LintCode "Coins in a Line"

    Recursion + Memorized Search(DP). And apparently, the code below can be iterative with only 3 vars - ...

  8. android下asynchttp库对于session的支持

    默认asynchttp库不支持session,需要用户配置下cookie来处理,直接贴支持session的代码 package example.com.sessiontest; import andr ...

  9. [tty与uart]3.tty驱动分析

    转自:http://www.wowotech.net/linux_kenrel/183.html 目录: 1 首先分析设备驱动的注册 1.1 uart_register_driver分析 1.2 tt ...

  10. jetty-run运行报错的原因