xk6_jsonparser

package module
v0.0.0-...-8f6bd16 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 26, 2026 License: AGPL-3.0 Imports: 2 Imported by: 0

README

xk6-jsonparser

An extension for the k6 load testing tool that allows JSON marshal & unmarshal in Go, using the bytedance/sonic library. This provides better performance than the native JavaScript JSON methods using the underlying Sobek implementation (see the benchmarks section for more details).

Install

To build a k6 binary with this extension, first ensure you have the prerequisites:

Then:

  1. Download xk6:
go install go.k6.io/xk6/cmd/xk6@latest
  1. Build the k6 binary:
xk6 build --with github.com/InditexTech/xk6-jsonparser@latest

Alternatively, you can build a k6 binary with the extension from the local code, rather than from GitHub:

make build
Development

The default target in the Makefile will download the dependencies, format your code, run the tests and the example.

git clone git@github.com:InditexTech/xk6-jsonparser.git
cd xk6-jsonparser
make

Usage

This extension provides two methods:

import json from "k6/x/json";

export default function() {
  // Convert a JS object to a JSON string.
  // If the operation fails, the output is an empty string.
  const marshalResult = json.marshal({userId: 1, userName: "Lorem ipsum"});
  
  // Convert a JSON string to a JS object.
  // If the operation fails, the output is a null value.
  const unmarshalResult = json.unmarshal('{"userId": 2, "userName": "Dolor sit amet"}');
}

See the examples folder for a more detailed usage example.

Contributing

Contributions are welcome! Please see the CONTRIBUTING.md file for guidelines on how to contribute to this project.

License

This project is licensed under the terms of the AGPL-3.0-only license.

© 2025 INDUSTRIA DE DISEÑO TEXTIL S.A. (INDITEX S.A.)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RootModule

type RootModule struct{}

RootModule is the global module object type. It is instantiated once per test run and will be used to create `k6/x/json` module instances for each VU.

func (*RootModule) NewModuleInstance

func (*RootModule) NewModuleInstance(vu modules.VU) modules.Instance

NewModuleInstance implements the modules.Module interface to return a new instance for each VU.

Directories

Path Synopsis
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL