parsing - 这是什么类型的数据格式(冒号和分号分隔的条目)?

标签 parsing format dataformat data-formats

我正在集成两个记录不完整的系统,在此过程中我遇到了一种我以前从未见过的奇怪数据格式。它以纯文本形式存储在数据库中,没有说明格式是什么以及如何处理它。

a:17:{s:2:"id";s:27:"145219921F990B11C39E7220000";s:16:"purchase_country";s:2:"no";s:17:"purchase_currency";s:3:"nok";s:6:"locale";s:5:"nb-no";s:6:"status";s:17:"checkout_complete";s:9:"reference";s:27:"145212221F990B11C39E7221000";s:11:"reservation";s:10:"2348226550";s:10:"started_at";s:25:"2014-04-04T10:40:55+02:00";s:12:"completed_at";s:25:"2014-04-02T10:41:11+02:00";s:16:"last_modified_at";s:25:"2014-04-02T10:41:11+02:00";s:10:"expires_at";s:25:"2014-04-16T10:41:11+02:00";s:4:"cart";a:4:{s:25:"total_price_excluding_tax";i:489500;s:16:"total_tax_amount";i:0;s:25:"total_price_including_tax";i:489500;s:5:"items";a:2:{i:0;a:10:{s:9:"reference";s:2:"68";s:4:"name";s:21:"1.OSO SUPER S 200LIT.";s:8:"quantity";i:1;s:10:"unit_price";i:695000;s:8:"tax_rate";i:0;s:13:"discount_rate";i:0;s:4:"type";s:8:"physical";s:25:"total_price_including_tax";i:695500;s:25:"total_price_excluding_tax";i:694000;s:16:"total_tax_amount";i:0;}i:1;a:10:{s:9:"reference";s:2:"68";s:4:"name";s:32:"1.OSO SUPER S 200LIT. (discount)";s:8:"quantity";i:1;s:10:"unit_price";i:-205100;s:8:"tax_rate";i:0;s:13:"discount_rate";i:0;s:4:"type";s:8:"physical";s:25:"total_price_including_tax";i:-205100;s:25:"total_price_excluding_tax";i:-205100;s:16:"total_tax_amount";i:0;}}}s:8:"customer";a:1:{s:4:"type";s:6:"person";}s:16:"shipping_address";a:8:{s:10:"given_name";s:13:"Testperson-no";s:11:"family_name";s:8:"Approved";s:14:"street_address";s:18:"Sæffleberggate 56";s:11:"postal_code";s:4:"0563";s:4:"city";s:4:"OSLO";s:7:"country";s:2:"no";s:5:"email";s:32:"omitted@testdrive.klarna.com";s:5:"phone";s:11:"40 12 34 56";}s:15:"billing_address";a:8:{s:10:"given_name";s:13:"Testperson-no";s:11:"family_name";s:8:"Approved";s:14:"street_address";s:18:"Sæffleberggate 56";s:11:"postal_code";s:4:"0563";s:4:"city";s:4:"OSLO";s:7:"country";s:2:"no";s:5:"email";s:32:"checkout-no@testdrive.klarna.com";s:5:"phone";s:11:"40 12 34 56";}s:7:"options";a:1:{s:31:"allow_separate_shipping_address";b:0;}s:8:"merchant";a:5:{s:2:"id";s:4:"1601";s:9:"terms_uri";s:95:"omitted";s:12:"checkout_uri";s:59:"omitted";s:16:"confirmation_uri";s:220:"omitted";s:8:"push_uri";s:229:"omitted";}} 

条目由冒号分隔的段组成:

  • 单个字符类型标签(数组、对象、整数、小数、 bool 、字符串)
  • 一个数字,表示该值在字符、字节、元素(在数组的情况下)或键值对(在 objs 的情况下)中的长度,这似乎完全没用,因为这是一种需要我的文本格式无论如何都要解析长度段。这不适用于整数和小数。
  • 领域的值(value)
  • 键值对似乎是一个包含偶数个元素的平面列表。他们似乎也将数组用作对象(参见示例)。
  • 一个;终止符,对于对象和数组来说似乎不是必需的,只是为了让解析更乏味。

现在,解析这个东西相当容易,但我总是对新的数据类型和它们奇怪的语法感到惊讶,我不确定我是否已经用我得到的少数数据样本涵盖了所有边缘情况分析了。有人熟悉这种格式吗?

最佳答案

关于parsing - 这是什么类型的数据格式(冒号和分号分隔的条目)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28171004/

相关文章:

c# - 数字格式在 ASP.NET Core 中不起作用

java - Apache POI : Excel changes my format string

c# - 知道字符串是长字符串还是 Guid 的最佳方法是什么?

javascript - 如何解析 bbcode 正则表达式?

windows - 在 Windows 上从文件手动创建 git 树 (Git Bash)

excel - 使用货币格式设置多范围列表框的格式

java - 如何在Java中将字节数组写入二进制文件

html - 从查询 url 获取 HTML (index.php?[arguments] ) Swift 3 ios

php - 在 PHP 中处理大型 XML 的最佳方式

C int打印格式化问题