fastjson 的简单说明及使用
fastjson 是一个性能很好的 Java 语言实现的 JSON 解析器和生成器,来自阿里巴巴的工程师开发。
各个版本jar包下载地址:https://repo1.maven.org/maven2/com/alibaba/fastjson/
主要特点:
快速FAST (比其它任何基于Java的解析器和生成器更快,包括jackson)
强大(支持普通JDK类包括任意Java Bean Class、Collection、Map、Date或enum)
零依赖(没有依赖其它任何类库除了JDK)
使用说明:fastjson的最主要的使用入口是com.alibaba.fastjson.JSON,具体见下面代码:
package com.test; import java.util.HashMap;
import java.util.Map; import com.alibaba.fastjson.JSON;
import com.test.entity.User; public class FashJsonTest { public static void main(String[] args) {
//实体类 -->> json字符串
User user = new User("张三", "男", 26);
String userJson = JSON.toJSONString(user);
System.out.println(userJson);
//json字符串 -->> 实体类
User newUser = JSON.parseObject(userJson,User.class);
System.out.println(newUser.getName()); //Map -->> json字符串
Map <String,String> map = new HashMap<String,String>();
map.put("date", "2015-07-24");
System.out.println(JSON.toJSONString(map));
//Map -->> json字符串
Map <String,Object> objMap = new HashMap<String,Object>();
objMap.put("curUser", user);
System.out.println(JSON.toJSONString(objMap));
}
}
运行结果:
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAuwAAACACAIAAADf66ujAAAToElEQVR4nO2d2aGrOgxFqYuCqIcSXhU0QzF5Hwkg2ZIHMAk+d62vDOBBFtZGZhheAAAAAB0y/LoBAAAAAGdAxAAAAECXIGIAAACgSxAxAAAA0CWIGAAAAOgSRAwAAAB0CSIGAAAAugQRAwAAAF2CiAEAAIAuQcQAAABAl/xOxKzzOIzzemcVy3R3Dd+v6V9lmYZpeV1zmy+43N/jMNo2BP8antscB/06jx2Zxmlt1dHBofQIkofkOo//xhAhYiTrPA4HFfv6NTWSN8s0hLSYNT/F7kXdJcbWebzY4J+JmI+J3P3EyKgOxqZU3vXUmBcdAu1ETCrUi2pDK4qfhU0dT23gwFERV0TMMqXGWvfO+c/vT5HRbD+sFDHFNnk2R89t0zk2jwZRzcaWGfRR5I+iN4LbX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AcYLR0kRE++QvCbmyMUrORCQydxUUmuHqEnpTIzf/gvNlSUEcuO0mPNFjNlfT8S07m9ArELSIub7VPnw8ff9SuCyfbakW+nvAABtSGdiKpLY1ZmYShEjN7IzGYmSLnHWDmI/ceHIUJDTOIMV7oLcS3MR4/S3MBNzG6Z2eYiOeb1ehT78ktcitb7NJxROFqVllZ3CAADcQZtrYrybYI75V11W4c1vajGkRBl58/up+fP6NTHh5Q1bae6C1Kn45MkV50TYXsLbWlh8uaglYpz+uiKmXX+TfFHElNtQUeLD4o9ys53J3JiWqTAXF/YCwO9odneSzIvbi0CiPF9kGPc4hTl31Sj9l7yw9wciRt9nsuj+DkY7vfZXtlMlenRBovyoE8W5fn85yeyvL2Ia9TfD4NxifYeOqbJhhQ8H9yOV3p503laFvxsgYgDgd7S7xfrPctkOYQ7kKY8B8/JnvSNVy3D6zuEyurZhwhqIGADogson9v6TXLVDsNbzhLs21u0xLj9tRXMC1ZJIM5SQqaxnGyY6WNR3AZfEAMAPSc5WW577X5+LLtshsZYA0CufxUR7nRI/B4Av8JxbNgAAAAAqQMQAAABAlyBiAAAAoEsQMQAAANAliBgAAADoEkQMAAAAdAkiBgAAALoEEQMAAABdgogBAACALkHEAAAAQJcgYgAAAKBLEDEAAADQJYgYAAAA6BJEDAAAAHQJIgYAAAC6BBEDAAAAXYKIAQAAgC5BxAAAAECXIGIAAACgSxAxAAAA0CWIGAAAAOgSRAwAAAB0CSIGAAAAugQRAwAAAF2CiAEAAIAuQcQAAABAlyBiAAAAoEsQMQAAANAliBgAAADoEkQMAAAAdMn/raK8TQsdUb4AAAAASUVORK5CYII=" alt="" />
fastjson 的简单说明及使用的更多相关文章
- 高性能JSON框架之FastJson的简单使用
1.前言 1.1.FastJson的介绍: JSON协议使用方便,越来越流行,JSON的处理器有很多,这里我介绍一下FastJson,FastJson是阿里的开源框架,被不少企业使用,是一个极其优秀的 ...
- Android原生json和fastjson的简单使用
android原生操作json数据 主要是两个类 JSONObject 操作对象 JONSArray操作json数组 对象转json //创建学生对象 Student student=new ...
- FastJson的简单实用
一.FastJson的理解 在工作中,经常客服端需要和服务端进行通信,目前很多项目都采用JSON的方式进行数据传输,简单的参数可以通过手动拼接JSON字符串,但如果请求的参数过多,采用手动拼接JSON ...
- FastJson的简单使用(alibaba)
原文章:http://blog.csdn.net/glarystar/article/details/6654494 原作者:张星的博客 maven配置: <dependency> < ...
- fastjson的简单使用
实习初期,开始接触到系统的后台日志查询展示到前台,后台将查询到的数据转化成json格式返回前台,发现系统使用的是阿里的fastjson,于是想来了解一下fastjson的使用. 以下使用都是基于这个版 ...
- Fastjson 的简单使用<转>
简介 Fastjson是一个Java语言编写的高性能功能完善的JSON库. 高性能 fastjson采用独创的算法,将parse的速度提升到极致,超过所有json库,包括曾经号称最快的jackson. ...
- JSON解析工具——fastjson的简单使用
从官方文档入手: 常见问题与快速上手:https://github.com/alibaba/fastjson/wiki/%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98 各种使 ...
- fastjson过滤器简单记录
fastjson过滤器,该字段可以将转化的json字段遍历,方便实用 1 /** * 通用输出json * @param object * @return json字符串 */ public Stri ...
- fastjson JSONObject简单使用
工作中用的蛮多的最近整理下,概括地说 通过这个工具可以让一个json在json串,JSONObject,java对象之间进行转化 首先我们先写2个bean来构成一个比较复杂的json串: public ...
随机推荐
- C++线程类的封装
简单的C++线程操作的封装,使用了智能指针管理对象的释放. 可运行对象基类 class SimpleRunable:public RefCountedBase { public: SimpleRuna ...
- Best Time to Buy and Sell Stock III 解题思路
题目要求: 最多交易两次,并且只能买卖完之后再买. 总思路: 在数组中找一个适当的点i,使得i左右两边profit之和最大. 思路: 1.从左往右扫描,left[i]记录包括i元素以内的左部的maxp ...
- DB2 WIN7 WIN8在指示的文件系统中找不到数据库目录
前言:win7下一些软件的不正常,跟win7的权限有很大关系. 在win7下安装db2 9.7客户端后,在cmd中运行db2cmd启动clp,输入db2的任何命令都显示:SQL ...
- PHPCMS GET标签使用
大纲: get 标签概述get 标签语法get 标签创建工具get 调用本系统示例get 调用其他系统示例一.get 标签概述 通俗来讲,get 标签是Phpcms定义的能直接调用数据库里面内容 ...
- boost之algorithm/string
头文件: #include<iostream>#include <boost/algorithm/string.hpp>using namespace std;using na ...
- 查看yum包安装地址
首先找到包含版本号在内的全包名 rpm -qa|grep t_dp_apsara_exstoret_dp_apsara_exstore-1.0.5-56 然后就可以查询到了 rpm -ql t_dp_ ...
- uboot环境变量初始化
一.环境变量概述 1.环境变量的概念 可以理解为用户对软件的全局配置信息,这部分信息应该可以从永久性存储器上读取,能被查询,能被修改. 启动过程中,应该首先把环境变量读取到合适的内存区域,然后利用环境 ...
- MAC OX 配置JDK环境变量
大家在windows里面配置JDK环境变量很容易,但是如果要在mac里面配置JDK环境变量和windows里面有所不同,具体如下: 第一: mac OS里面自带jdk,不过是1.6的版本,现在很多人使 ...
- C语言之 短路原则
a=0;b=1 c=a&&(b=3) 最终c=0; b=1 因为从左至右进行时,若遇到运算符左边的操作数是 0(逻辑假),则停止运算. a=1;b=1;c=0; d=a||b||(c= ...
- bzoj 3669: [Noi2014]魔法森林 动态树
3669: [Noi2014]魔法森林 Time Limit: 30 Sec Memory Limit: 512 MBSubmit: 363 Solved: 202[Submit][Status] ...