seo.json_formatter.how_desc
- seo.json_formatter.how_step1
- seo.json_formatter.how_step2
- seo.json_formatter.how_step3
- seo.json_formatter.how_step4
seo.json_formatter.how_example
JSON verilerini biçimlendirin ve doğrulayın. JSON dizelerini güzelleştirin veya küçültün.
JSON biçimlendirici, dağınık, biçimlendirilmemiş JSON verilerini doğru girintili ve satır sonlarıyla temiz, okunabilir bir formata dönüştüren bir araçtır. Ayrıca JSON'unuzun sözdizimsel olarak doğru olup olmadığını da doğrular.
seo.json_formatter.how_desc
seo.json_formatter.how_example
JSON (JavaScript Object Notation), Douglas Crockford tarafından belirtildi ve RFC 8259 (2017) ile standartlaştırıldı. JSON, JavaScript nesne sözdizimini temel alan hafif, dilden bağımsız bir veri formatıdır. Web API'ları, yapılandırma dosyaları ve veri değişimi için baskın format haline geldi ve birçok uygulamada XML'i büyük ölçüde değiştirdi.
JSON formatting does not validate data safety. Always validate and sanitize JSON content from untrusted sources before using it in your application. Learn about encoding security
Her programlama dili JSON biçimlendirebilir (güzelleştirebilir) ve küçültebilir. İşte örnekler:
// Beautify (pretty print)
$formatted = json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
// Result: formatted with 4-space indent
// Minify (compact)
$minified = json_encode($data);
// Result: no whitespace
// With custom options
$json = json_encode($data,
JSON_PRETTY_PRINT |
JSON_UNESCAPED_UNICODE |
JSON_UNESCAPED_SLASHES
);
// Parsing (with error handling)
$data = json_decode($jsonString, true);
if (json_last_error() !== JSON_ERROR_NONE) {
echo "JSON Error: " . json_last_error_msg();
}
// Beautify with 2-space indent
const formatted = JSON.stringify(data, null, 2);
// Beautify with 4-space indent
const formatted = JSON.stringify(data, null, 4);
// Minify (compact)
const minified = JSON.stringify(data);
// Parse with error handling
try {
const data = JSON.parse(jsonString);
} catch (error) {
console.error("JSON parse error:", error.message);
}
// Replacer function (custom serialization)
const json = JSON.stringify(data, (key, value) => {
// Exclude private fields
if (key.startsWith('_')) return undefined;
return value;
}, 2);
import json
# Beautify with 2-space indent
formatted = json.dumps(data, indent=2)
# Beautify with sorted keys
formatted = json.dumps(data, indent=2, sort_keys=True)
# Minify (compact)
minified = json.dumps(data, separators=(',', ':'))
# separators removes spaces after commas and colons
# Parse with error handling
try:
data = json.loads(json_string)
except json.JSONDecodeError as e:
print(f"JSON error: {e.msg} at line {e.lineno}")
# Pretty print to console
print(json.dumps(data, indent=2))
import (
"encoding/json"
"fmt"
)
// Beautify with indent
formatted, err := json.MarshalIndent(data, "", " ")
if err != nil {
fmt.Println("JSON marshal error:", err)
}
// Minify (compact)
minified, err := json.Marshal(data)
// Parse with error handling
var data MyStruct
err := json.Unmarshal([]byte(jsonString), &data)
if err != nil {
fmt.Println("JSON unmarshal error:", err)
}
// Custom indentation
formatted, _ := json.MarshalIndent(data, ">", "----")
// Prefix: >, indent: ----
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonSyntaxException;
// Beautify
Gson gson = new GsonBuilder()
.setPrettyPrinting()
.create();
String formatted = gson.toJson(data);
// Minify
Gson gson = new Gson();
String minified = gson.toJson(data);
// Parse with error handling
try {
MyObject obj = gson.fromJson(jsonString, MyObject.class);
} catch (JsonSyntaxException e) {
System.err.println("JSON error: " + e.getMessage());
}
require 'json'
# Beautify
formatted = JSON.pretty_generate(data)
# Default: 2-space indent
# Beautify with custom indent
formatted = JSON.pretty_generate(data, indent: ' ')
# 4-space indent
# Minify
minified = JSON.generate(data)
# Parse with error handling
begin
data = JSON.parse(json_string)
rescue JSON::ParserError => e
puts "JSON error: #{e.message}"
end
using Newtonsoft.Json;
// Beautify (pretty print)
string formatted = JsonConvert.SerializeObject(data,
Formatting.Indented);
// Minify (compact)
string minified = JsonConvert.SerializeObject(data,
Formatting.None);
// Parse with error handling
try
{
var obj = JsonConvert.DeserializeObject<MyObject>(jsonString);
}
catch (JsonException ex)
{
Console.WriteLine($"JSON error: {ex.Message}");
}
Working with JWT tokens? Our JWT Decoder decodes and formats the JSON header and payload from JWT tokens.
Have Base64-encoded JSON? First use our Base64 Decoder to decode, then format the resulting JSON.
Passing JSON in URL parameters? Encode it with our URL Encoder after minifying for compact URLs.