Python JSON dummy data generation from JSON schema
Asked Answered
C

3

24

I am looking for a python library in which I can feed in my JSON schema and it generates dummy data. I have worked with a similar library in javascript dummy-json. Does anyone about a library which can do the same in python.

Carey answered 5/2, 2016 at 18:38 Comment(5)
Faker combined with json?Killerdiller
Similar to this: npmjs.com/package/dummy-jsonCarey
Right, you could make something similar to that using Faker and the json module.Killerdiller
Should not this be a duplicate of #12466088Reproval
I can't believe how this simple question was misinterpreted by so many.Jacqui
I
6

A library that does exactly this is hypothesis-jsonschema

Hypothesis is a library that can generate arbitrary data that conforms to a given specification.

hypothesis-jsonschema makes it possible to convert JSON Schema into specifications that can be used by Hypothesis.

Here is an example showing a unit test written using Hypothesis and hypothesis-jsonschema:

from hypothesis import given

from hypothesis_jsonschema import from_schema


@given(from_schema({"type": "integer", "minimum": 1, "exclusiveMaximum": 10}))
def test_integers(value):
    assert isinstance(value, int)
    assert 1 <= value < 10
Inebriety answered 7/6, 2021 at 16:9 Comment(0)
S
1

The most closest what I found within python is https://github.com/ueg1990/faker-schema, but it is not JSON-SCHEMA also there is nodejs implementation that is directly what you are searching for https://github.com/json-schema-faker/json-schema-faker

Spatial answered 5/7, 2018 at 11:51 Comment(0)
T
-2

here are the JSON schema generators proposed so far:

bonus:

Tien answered 5/2, 2016 at 19:35 Comment(2)
I dont want to generate schema. I have a schema or maybe one sample JSON. I want to generate random data from that. It should be random every timeCarey
@Carey online: + schematic-ipsum.herokuapp.com + experiments.mennovanslooten.nl/2010/mockjson/tryit.html + json-generator.com + json-generator.appspot.com python, perhabs this is help to you: + github.com/hamstah/apitools + joke2k.net/fakerHanny

© 2022 - 2024 — McMap. All rights reserved.