
Three small things come up in almost every software project: reading JSON, converting timestamps and creating unique IDs. This guide explains each in plain English and links to a free tool for each one.
JSON: how to read it and fix it
JSON is plain text with objects in braces, lists in square brackets and keys in double quotes. A small example looks like {"name": "Ada", "tags": ["math", "code"]}. When a JSON file will not load, the cause is usually one of three things: a comma after the last item, single quotes instead of double quotes, or a missing closing brace. Paste your text into the JSON formatter to validate it and pretty-print it. The formatter points to the place where the syntax breaks, which is much faster than reading a long line by eye.
JSON looks like a JavaScript object, but it is stricter. Keys must be in double quotes, there are no comments, and functions cannot be stored. If you need comments in a settings file, a different format may suit you better.
Timestamps
A Unix timestamp counts seconds since January 1, 1970, UTC. The number 1700000000 is November 14, 2023. Some systems use milliseconds instead, which has 13 digits instead of 10 and makes the number 1000 times larger. If a date comes out in the year 50000 or in 1970, you probably mixed up seconds and milliseconds. Convert in both directions with the timestamp converter.
Timestamps are usually stored in UTC. A single reference avoids confusion between time zones, and you convert to local time only when you show the date to a person. Daylight saving changes are another reason to store UTC: a local time can happen twice or not at all on the day the clocks change.
UUIDs
A UUID is a 128-bit identifier written as 32 hexadecimal digits in groups, such as 123e4567-e89b-12d3-a456-426614174000. A version 4 UUID has 122 random bits. The chance of two matching is extremely small, so they work as record IDs without a central counter. A UUID is an identifier, not a secret. Do not use it as a password or a security token. Make some with the UUID generator.
Also useful
- Base64 encoder and decoder: Base64 turns bytes into text so they can travel in a URL or an email. It is an encoding, not encryption. Anyone can decode it.
- JWT decoder: shows what is inside a login token. Decoding does not check the signature, so a decoded token is not proof that it is genuine.
- Regex tester: try a pattern on sample text before you put it in code.
- Hash generator: create a checksum to compare a downloaded file with the one the publisher lists.
A short debugging routine
When data looks wrong, change one thing at a time. First confirm the text is valid JSON. Then check that dates are in seconds or milliseconds as you expect. Then check that IDs are not cut off by a spreadsheet or a database column that is too short. Writing down each check keeps you from repeating the same one twice.
Working safely with online tools
These tools run in your browser, so the text you type is not sent to our server. Even so, it is good practice to remove passwords, API keys and personal data from anything you paste into a web page. Replace them with dummy values while you debug. Keep a copy of the original data before you reformat it.
Frequently asked questions
Why are timestamps in UTC?
A single reference avoids confusion between time zones.
Is JSON the same as a JavaScript object?
Close, but not the same. JSON needs double-quoted keys and has no comments or functions.
Are UUIDs unique forever?
Random UUIDs are not guaranteed unique, but a clash is so unlikely that systems treat them as unique.
Are these tools safe for real data?
They run in your browser. Still, remove secrets before pasting anything online.
No comments:
Post a Comment