• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

bennadel/JsonSerializer.cfc: A JavaScript Object Notation (JSON) serialization u ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

bennadel/JsonSerializer.cfc

开源软件地址:

https://github.com/bennadel/JsonSerializer.cfc

开源编程语言:

ColdFusion 66.3%

开源软件介绍:

JsonSerializer.cfc - Data Serialization Utility for ColdFusion

by Ben Nadel

ColdFusion is a case insensitive language. However, it often has to communicate with languages, like JavaScript, that are not case sensitive. During the data serialization workflow, this mismatch of casing can cause a lot of headaches, especially when ColdFusion is your API-back-end to a rich-client JavaScript front-end application.

JsonSerializer.cfc is a ColdFusion component that helps ease this transition by performing the serialization to JavaScript Object Notation (JSON) using a set of developer-defined rules for case-management and data-conversion-management. Essentially, you can tell the serializer what case to use, no matter what case the data currently has.

Methods

  • asAny( key ) - Simply defines the key-casing, without any data conversion.
  • asBoolean( key ) - Attempts to force the value to be a true boolean.
  • asDate( key ) - Converts the date to an ISO 8601 time string.
  • asFloat( key ) - Attempts to force the value to be a true float.
  • asInteger( key ) - Attempts to force the value to be a true integer.
  • asString( key ) - Forces the value to be a string (including numeric values).
  • exclude( key ) - Will exclude the key from the serialization process.

All-or-Nothing

The keys are defined using an all-or-nothing approach. By that, I mean that the serializer doesn't care where it encounters a key - if it matches, it will be given the explicitly defined casing. So, if you want to use "id" in one place and "ID" in another place within the same data-structure, you're out of luck. Both keys will match "id" and will be given the same case.

API Philosophy

This is primarily intended to be used to return data from a server-side API. As part of that use-case, some of my philosophy is baked into it. Namely, an API usually returns a top-level struct / hash-map that defines the API result. This is why the serialization process is driven by the name of keys.




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
circlecell/jsonlintpro发布时间:2022-07-09
下一篇:
openresty/rds-json-nginx-module: An nginx output filter that formats Resty DBD S ...发布时间:2022-07-09
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap