分享

JSON Generator – tool for generating random JSON data

 GreatStep 2014-01-15

http://www./

Help

{{index}} Integer
Returns the index of current cloned object starting from 1.
{{numeric(a, b, format)}} Integer or Float
Can be negative. Generates random number in range from "a" to "b". If "a" is float, generated number will be float too. Generated number can be formatted according to "format" string. For more information visit Numeral.js.
{{bool}} Boolean
Generates random true/false
{{firstName(gender)}}, {{surname}} String
Generates random name, surname. Param "geneder" — string containing male or female.
{{gender}} String
Generates gender based on {{firstName}} that are called before of it or random value.
{{company}} String
Generates random company name.
{{phone(mask)}} String
Generates random phone number. Generated phone can be formatted according to "mask" string which contains "x" letters which will be replaced with digits.
{{email(random)}} String
Generates email based on {{firstName}}, {{surname}} and {{company}} that are called before of it. If param "random" is true — generates random email address.
{{countriesList}} Array
Returns a list of 205 unique countries.
{{country}} String
Generates random country.
{{state}} String
Generates random US state.
{{city}} String
Generates random US city.
{{street}} String
Generates random US street.
{{date(format)}} String

Generates random date that can be formatted according to "format" string. Format string may consist of any characters, but some of them considered tokens, and will be replaced by appropriate value from date.

Possible tokens include:

  • YYYY: 4-digit year
  • YY: last 2 digit of year
  • MM: ISO8601-compatible number of month (i.e. zero-padded) in year (with January being 1st month)
  • M: number of month in year without zero-padding (with January being 1st month)
  • dd: zero-padded number of day in month
  • d: number of day in month
  • hh: zero-padded hour
  • h: hour
  • mm: zero-padded minutes
  • m: minutes
  • ss: zero-padded seconds
  • s: seconds
  • TZ: time-zone in ISO8601-compatible format (i.e. "-04:00")

Longer tokens take precedence over shorter ones (so "MM" will aways be "04", not "44" in april).

{{guid}} String
Generates random globally unique identifier.
{{lorem(count, units)}} String
Generates Lorem Ipsum according to "count". Units can be "words", "sentences" or "paragraphs".
function(idx) { ... } Any valid
You can create your own function, that returns any value. Passed params: "idx" (index of current cloned object). "this" keyword contains generation methods which has same names as the tags.

About

We've all faced the problem of lack of information in our app. All interfaces seem lifeless and empty. Debugging with no data is also not simple.

I think that each of us has at least once in their lives created a bunch of files with JSON data, but they were just one object propagated without unique fields. JSON Generator was created in order to help with this. It provides an opportunity generate any data and in any quantity. Edit template, click "Generate" and you're done.

Usage

JSON Generator has a convenient syntax. You can specify JavaScript object for template that you see in the left box. It will be cloned in infinite depth. Fields may have any name and value, but it must be valid JavaScript. Values, which are strings, may contain one or more template tags. When you click "Generate" the data source object to be copied several times and the place of tags will be inserted random values.

You can copy the generated JSON to clipboard by clicking "Copy to clipboard". If you click "Upload", JSON will be stored on the server and you can download generated file by clicking "Download" button or access it via ajax-request by URL that will be copied to clipboard after clicking "Copy URL" button. Yes, JSON Generator can JSONP :) Generated files are stored 30 days and their size does not exceed 500 kB. Size appears at the top right of the field with the generated data. If file size text is red - file is too large for saving on server, but you can copy it to your clipboard and save locally to *.json file.

You can choose indentation for the generated JSON from the drop-down list. Also when you copy the link to uploaded code there is an "indent" param in URL. It can has values of 2, 3 and 4. If param is not specified code will be compact.

JSON Generator remembers your last template in localStorage. If you want to reset it, click "Reset" button to reset template and UI.

If you have found a bug, you have a suggestion for improving the application or just want to thank me, click on "Feedback".

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约