Formatera och indentera JSON

omvandlar JSON till en läsbar, strukturerad form, perfekt för att inspektera REST-API-svar, konfigurationer och loggar

Pourquoi le formatage JSON ?

Le formatage JSON permet de rendre les données JSON plus lisibles et compréhensibles pour les développeurs et les utilisateurs. Cela facilite le débogage, la revue de code et l'analyse des données, en particulier lorsqu'il s'agit de fichiers JSON complexes et volumineux. Un JSON bien formaté peut également être intégré plus facilement dans les documents et les rapports.

Comment formater du JSON

Sur la page de formatage, vous pouvez formater votre JSON en le collant dans la zone de texte prévue à cet effet ou en téléchargeant un fichier contenant du JSON.

Uui

Dès que le JSON est soumis, il sera formaté et affiché dans une zone de résultat. Si le JSON est invalide, une erreur sera affichée avec une indication de la nature du problème.

Utiliser le JSON formaté

Vous pouvez copier le JSON formaté en utilisant le bouton de copie prévu à cet effet. Cela facilitera l'intégration du JSON dans vos projets ou rapports.

Votre code JSON devrait ressembler à ceci :


{
    "id": 12345,
    "name": "John Doe",
    "email": "johndoe@example.com",
    "address": {
        "street": "123 Main St",
        "city": "Springfield",
        "state": "IL",
        "postalCode": "62704",
        "country": "USA"
    },
    "phoneNumbers": [
        {
            "type": "home",
            "number": "555-1234"
        },
        {
            "type": "work",
            "number": "555-5678"
        }
    ],
    "orders": [
        {
            "orderId": 1001,
            "orderDate": "2023-06-01T14:30:00Z",
            "items": [
                {
                    "productId": 2001,
                    "productName": "Laptop",
                    "quantity": 1,
                    "price": 999.99,
                    "details": {
                        "manufacturer": "TechCorp",
                        "warranty": "2 years"
                    }
                },
                {
                    "productId": 2002,
                    "productName": "Mouse",
                    "quantity": 2,
                    "price": 25.50,
                    "details": {
                        "manufacturer": "GadgetCo",
                        "warranty": "1 year"
                    }
                }
            ],
            "totalAmount": 1051.49
        },
        {
            "orderId": 1002,
            "orderDate": "2023-06-10T10:15:00Z",
            "items": [
                {
                    "productId": 2003,
                    "productName": "Keyboard",
                    "quantity": 1,
                    "price": 45.99,
                    "details": {
                        "manufacturer": "KeyMasters",
                        "warranty": "3 years"
                    }
                }
            ],
            "totalAmount": 45.99
        }
    ],
    "preferences": {
        "newsletter": true,
        "notifications": {
            "email": true,
            "sms": false
        },
        "theme": "dark"
    },
    "lastLogin": "2024-06-14T09:30:00Z"
}

        

Exempelförfrågan

curl -X POST https://cdrn.fr/api/v1/tools/json-formatter/execute \
  -H "Content-Type: application/json" \
  -d '{"input":"..."}'

Indatasschema

Fält Typ Obligatorisk Standard
input text

Slutpunkter

  • GET https://cdrn.fr/api/v1/tools - listar alla tillgängliga verktyg
  • GET https://cdrn.fr/api/v1/tools/json-formatter - hämtar schemat för detta verktyg
  • POST https://cdrn.fr/api/v1/tools/json-formatter/execute - kör detta verktyg med en JSON-payload