haesleinhuepf / git-bob-playground

BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

[Programming question]: YAML JSON comparison #117

Open haesleinhuepf opened 3 days ago

haesleinhuepf commented 3 days ago

git-bob comment on the differences between json and yaml. Come up with one example record (e.g. a customer in a database) and show the record in json and yaml.

github-actions[bot] commented 3 days ago

This message was generated by git-bob (version: 0.14.1dev, model: claude-3-5-sonnet-20241022, log), an experimental AI-based assistant. It can make mistakes and has limitations. Check its messages carefully.

Hi there! 👋 Let me show you a customer record in both formats:

%%writefile customer.json
{
    "customer_id": 123,
    "name": {
        "first": "John",
        "last": "Doe"
    },
    "contact": {
        "email": "john.doe@email.com",
        "phone": "+1-555-123-4567"
    },
    "preferences": [
        "email notifications",
        "weekly newsletter"
    ],
    "active": true,
    "last_purchase": "2024-02-15"
}
%%writefile customer.yaml
customer_id: 123
name:
  first: John
  last: Doe
contact:
  email: john.doe@email.com
  phone: +1-555-123-4567
preferences:
  - email notifications
  - weekly newsletter
active: true
last_purchase: 2024-02-15

Both formats represent exactly the same data structure, but YAML is generally considered more human-readable due to its indentation-based syntax and less punctuation. JSON is more compact and widely used for data exchange between systems.