Port of the TypeScript JSON parser to Visual Basic in .NET 8.0.
MIT
To build the project, ensure you have .NET 8.0 SDK installed. Run the following command in the root directory:
dotnet build
This will build all projects in the solution.
To format the code, use the .NET CLI formatter:
dotnet format json-vb.sln
To verify that no formatting changes are required:
dotnet format json-vb.sln --verify-no-changes
This will automatically format all VB files according to the standard rules.
To run the unit tests:
dotnet test
This will execute all tests in the JsonParser.Tests project and display the results.
The CLI application can be run to parse JSON input. Build the project first, then run:
dotnet run --project CLI
You can provide JSON input in several ways:
- Manual Entry: Run the CLI and type JSON directly, then press Ctrl+D (Linux/Mac) or Ctrl+Z (Windows) to end input.
dotnet run --project CLI
{"name": "example", "value": 42}
# Press Ctrl+D
- Using echo: Pipe JSON from echo.
echo '{"name": "example", "value": 42}' | dotnet run --project CLI
- From a File: Pipe JSON from a file.
cat sample.json | dotnet run --project CLI
Or using input redirection:
dotnet run --project CLI < sample.json
The solution includes a REST API that provides JSON parsing functionality via HTTP endpoints.
To run the API server:
dotnet run --project API
The API will start on:
- HTTP:
http://localhost:8000
- HTTPS:
https://localhost:8001
Parses JSON input and returns the parsed result.
Request:
- Method: POST
- Content-Type:
text/plain
- Body: Raw JSON string
Success Response (200):
- Content-Type:
text/plain
- Body: Pretty-printed JSON
Error Responses:
- 400 Bad Request: Invalid JSON syntax
{
"code": 400,
"message": "Error message describing the parsing issue"
}
- 415 Unsupported Media Type: Wrong content type
{
"code": 415,
"message": "Unsupported Media Type. Please use 'text/plain'."
}
The API includes test data files in the testdata/
directory that can be used with VS Code's REST Client extension for easy testing.
- Install the REST Client extension for VS Code
- Open any
.rest
file from thetestdata/
directory
- Start the API server (see above)
- Open any
.rest
file in VS Code - Click the "Send Request" link above each HTTP request in the file
- View the response in the REST Client output panel
POST http://localhost:8000/api/v1/parse
Content-Type: text/plain
{"name": "test", "value": 123}
This will send a POST request to the API with JSON content and display the parsed, pretty-printed result.