JSON SERVER
Fake rest api json server.

Template file

Singiel show
Pattern url - /api/{jsonTemplateName}/{1}
Example url - /api/person/12

{
  "type": "single",
  "cache" : false,  // support from version 1.1
  "auth" : {  // support from version 1.2
      "accounts" : {
          "user1" : "pass1",
          "user2" : "pass2",
          ....
          "user-n" : "pass-n"
      }
  },
  "variables" : {
    "$id" : "1"  // first parameter
  },
  "template": {
    "id" : "{$id}",  // insert varibles $id
    "gid" : "[guid]",
    "name" : "[firstname] [lastname]",
    "adrress" : "[city] [mask nn], [mask nn-nnn] [country]",
    "email" : "[email]",
    "show": "[bool]",
    "telephone" : "[mask 1 (nn) nnn-nnnn-nnnn]",
    "domian": "[www]",
    "float": "[float]",
    "friend" : "[json friend]",
    "friends" : "[json friend repeat:10]",
    "about-me" : "[lorem paragraphhtml 2]",
    "latitude": "[float -160 160 10]",
    "longitude": "[float -90 90 6]",
    "eyeColor": "[random blue brown green]",
    "company": "[company]",
    "avatar" : "[image]",
    "locations" : "[json loca repeat:5]"
  },
  "friend" : {
    "id" : "[id]",
    "name" : "[firstname] [lastname]",
    "avatar": "[image 60 60]",
    "loc" : "[json loc2 repeat:1:10]"
  },
  "loca" :{
    "gid" : "[guid]",
    "latitude": "[float -160 160 10]",
    "longitude": "[float -90 90 6]",
    "adrress" : "[city] [mask nn], [mask nn-nnn] [country]",
    "friend" : "[json friend repeat:2]"
  },
  "loc2" :{
    "gid" : "[guid]",
    "latitude": "[float -160 160 10]",
    "longitude": "[float -90 90 6]",
    "adrress" : "[city] [mask nn], [mask nn-nnn] [country]"
  }
}
Multiple show
Pattern url - /api/{jsonTemplateName}/{1}/{2}
Example url - /api/person/12/20


{
  "type": "multi",
  "start" : "{$start}",  // insert varibles $start
  "perPage" : "{$perPage}", // insert varibles $perPage
  "variables" : {
    "$start" : 1,  // first parameter
    "$perPage" : 2 // second parameter
  },
  "template": {
    "id" : "[id]",
    "gid" : "[guid]",
    "name" : "[firstname] [lastname]",
    "email" : "[email]"
  }
}

Option

cache
default false
support from version 1.1

{
    "cache" : {
        "expires" : "1d1h1m1s" // 90061 seconds
    }
}
{
    "cache" : {
        "expires" : "3h" // 259200 seconds
    }
}
  • Parameter
  • expires
    • d - day
    • h - hour
    • m - minute
    • s - second
auth
default false
support from version 1.2

{
    "cache" : {
        "accounts" : {
            "userexample" : "passw0rds"
        }
    }
}

curl --user userexample:passw0rds http://example.com/
OR

http -a userexample:passw0rds http://example.com/

Function

[id]
Return increment uniq id
[guid]
Return random uuid format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
[email]
Return random e-mail address
[company]
Return random company name from dictionary company.dict
[city]
Return random city from dictionary city.dict
[country]
Return random country from dictionary country.dict
[firstname]
Return random firstname from dictionary firstname.dict
{
    "firstanme" : "[firstname]"
}
{
    "firstanme" : "Clarissa"
}
[lastname]
Return random lastname from dictionary lastname.dict
[random $n1 $n2 ... $nn]
Return random element from parameter
[bool]
Return true or false
[www]
Return random www address from dictionary lastname.dict
[json $template_name $param]
Return geterate json from template
  • Param:
  • word
  • words
  • sentence
  • paragraph
  • paragraphhtml
[lorem $param]
Return random text
  • Param:
  • word
  • words
  • sentence
  • paragraph
  • paragraphhtml
[image $width $height]
Return image placeholder url
  • Param:
  • $width - (int) - default 640
  • $height - (int) - default 360
[mask nn-nnn]
  • Param:
  • n - number 0 - 9
  • a - lowercase
  • A - uppercase
  • x - hex 0 - F
{
    "zipcode" : "[mask nn-nnn]",
    "telephone" : "[mask 1 (nn) nnn-nnnn-nnnn]"
}
{
    "zipcode" : "85-150",
    "telephone" : "1 (63) 549-2184-5507",
}
[float min max precision]
  • min - (int) - 0
  • max - (int) - 100
  • precision - (int) - default 2
{
    "float1" : "[float]",
    "float2" : "[float -100 100 4]"
}
{
    "float1" : "45.03",
    "float2" : "-56.7384",
}

Licence

The MIT License

Copyright 2018 VeoLab.me

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Download

json-server.veo.1.2.zip
Changelog:
  • add basic WWW Authenticate