ballerina 学习六 xml && json
ballerina xml && json 参考使用
代码比较简单,使用起来还是比较方便的
xml
代码说明:
import ballerina/io;
function main (string… args) {
xml person1 = xml `<person><fname>John</fname><lname>Doe</lname></person>`;
xml person2 = xml `<person><fname>Jane</fname><lname>Doe</lname></person>`;
xml persons = xml `<persons/>`;
persons.setChildren(person1 + person2);
io:println(persons);
}
输出结果:
<persons>
<person><fname>John</fname><lname>Doe</lname></person>
<person><fname>Jane</fname><lname>Doe</lname></person>
</persons>
json
代码说明:
- 简单json
import ballerina/io;
function main (string… args) {
json j ={"name":"dalongdemo","age":333};
io:println(j);
}
输出结果:
{"name":"dalongdemo","age":333}
- 使用自定义类型
import ballerina/http;
import ballerina/io;
type Person {
string name;
int age;
string city;
};
function main (string… args) {
json<Person> person ={name:"dalong"};
person.age=11;
person.city="beijing";
io:println(person);
}
输出结果:
{"name":"dalong","age":11,"city":"beijing"}
参考资料
http://https//ballerina.io/learn/by-example/xml.html
https://ballerina.io/learn/by-example/json.html
ballerina 学习六 xml && json的更多相关文章
- iOS基础 - XML & JSON
一.HTML & XML HTML 是用来描述网页的一种语言 HTML 指的是超文本标记语言 (Hyper Text Markup Language) HTML 不是一种编程语言,而是一种标记 ...
- 模块简介:(random)(xml,json,pickle,shelve)(time,datetime)(os,sys)(shutil)(pyYamal,configparser)(hashlib)
Random模块: #!/usr/bin/env python #_*_encoding: utf-8_*_ import random print (random.random()) #0.6445 ...
- (转)MyBatis框架的学习(六)——MyBatis整合Spring
http://blog.csdn.net/yerenyuan_pku/article/details/71904315 本文将手把手教你如何使用MyBatis整合Spring,这儿,我本人使用的MyB ...
- day 84 Vue学习六之axios、vuex、脚手架中组件传值
Vue学习六之axios.vuex.脚手架中组件传值 本节目录 一 axios的使用 二 vuex的使用 三 组件传值 四 xxx 五 xxx 六 xxx 七 xxx 八 xxx 一 axios的 ...
- Xml,Json,Hessian,Protocol Buffers序列化对比
简介 这篇博客主要对Xml,Json,Hessian,Protocol Buffers的序列化和反序列化性能进行对比,Xml和Json的基本概念就不说了. Hessian:Hessian是一个轻量级的 ...
- Spring相关:jdom学习:读取xml文件
云课堂马士兵的spring2.5课程中提到的 用JDOM读取XML文件需先用org.jdom.input.SAXBuilder对象的build()方法创建Document对象,然后用Document类 ...
- xml json protobuf
本文为原创,转载请注明:http://www.cnblogs.com/gistao/ Background xml,json,protobuf都是格式化手段,喜欢哪个,会用哪个,该用哪个,用哪个? 随 ...
- iOS开发笔记3:XML/JSON数据解析
这篇主要总结在iOS开发中XML/JSON数据解析过程用到的方法.XML数据解析主要使用SAX方式的NSXMLParser以及DOM方式的GDataXML,JSON数据解析主要使用NSJSONSeri ...
- Silverlight项目笔记7:xml/json数据解析、TreeView、引用类型与数据绑定错误、图片加载、虚拟目录设置、silverlight安全机制引发的问题、WebClient缓存问题
1.xml/json数据解析 (1)xml数据解析 使用WebClient获取数据,获取到的数据实例化为一个XDocument,使用XDocument的Descendants(XName)方法获得对应 ...
随机推荐
- Docker 学习记录笔记(一)
Docker 一些简单的命令列表docker build -t friendlyhello . # Create image using this directory's Dockerfiledock ...
- keras运行gan的几个bug解决
http://blog.csdn.net/u012317000/article/details/79211274 https://www.jianshu.com/p/5b1f7004144d
- Pytorch入门笔记
import torch.nn as nn import torch.nn.functional as F class Net(nn.Module): def __init__(self): #nn. ...
- nyoj——113 getline
字符串替换 时间限制:3000 ms | 内存限制:65535 KB 难度:2 描述 编写一个程序实现将字符串中的所有"you"替换成"we" 输入 ...
- nyoj993——容斥
How many integers can you find 时间限制:1000 ms | 内存限制:65535 KB 难度:1 描述 给你三个数,n,m1,m2,找出所有小于n的能被m1或m ...
- kibana安装
kibana,ELK中的K,主要为ES提供界面化操作,据说还是比较炫的,今天安装5.5.2版本进行尝试一把. 安装过程不难,简单的配置了一下端口和IP即可,难度不大. config下的kibana.y ...
- (转)MapReduce Design Patterns(chapter 4 (part 2))(八)
Binning Pattern Description 分箱模式,跟前面的类似,分类记录且不考虑记录的顺序. Intent 归档数据集中的每条记录到一个或多个类别. Motivation 分箱和分区很 ...
- [Python] dict字典排序和多条件排序
利用lambda实现排序:要实现多条件排序,只需要依次指定排序的标准,具体实现如下 counter = {'是': 1, '不是': 1, '你': 3} counter_list = sorted( ...
- python基础第一章
Python基础 第一个python程序 变量 程序交互 基本数据类型 格式化输出 基本运算符 流程控制if...else... 流程控制-循环 第一个python程序 文件执行 1.用notepad ...
- iOS开发-UITextView文字排版
UITextView文本排版 1.配置NSMutableParagraphStyle NSMutableParagraphStyle *MParaStyle = [[NSMutableParagrap ...