# Creating input from JSON Schema

In this article we'll quickly set up a ruleset by importing the input and entities from a JSON Schema file.

Let's first create a subscriber ruleset that calculates the subscriber's age and the subscription amount.&#x20;

1. Create a ruleset named `Subscriber`.
2. Create a constant named `SubscriptionCostPerDay` and set its value to `0.10`.

Now the ruleset needs input; we're going to take a shortcut and define the input through importing a JSON schema. This will result in automatic creation of Input and Entities. Entities are like objects, and you can create them by hand, but if you have a JSON schema, there is a much quicker and easier way:&#x20;

3. Download the `SubscriberSchema.json` file to your workstation.

{% file src="/files/b6TemIScGlwa2akLm53S" %}

4. Open your file manager and head over to the folder where the `SubscriberSchema.json` file is located.
5. Drag the `SubscriberSchema.json` file to the **Entities** section in Rulecube and drop it.\
   ↳ Rulecube automatically creates a `SubscriberObject` entity based on the JSON schema:\ <img src="/files/aOwmsxJSfMH8JHKFzC9s" alt="" data-size="original">

   1. Alternatively, if your browser does not allow drag and drop, you may upload this file under the Ruleset's Settings > Tools page.

This is cool. Just drop a JSON schema, and you've got a basic entity. You can do the same with an XSD, by the way. For now, you need to tweak the entity a little:

6. Click on the SubscriberObject entity and add a calculated property named `Age` and set its **Expression** to:

```javascript
AGE(dateOfBirth)
```

7. Add another calculated property named `SubscriptionAmount` and set its **Expression** to calculate the subscription amount based on the remaining days in the current year and the subscription cost per day:<br>

```javascript
DAYDIFF(TODAY(), TODAY().endOfYear()) * SubscriptionCostPerDay
```

That's it; your entity is ready and includes the calculated properties that you need in your software. To finish the ruleset, you have to set its input and output based on the entity:

8. Create an input named `Subscriber` and set its type to `SubscriberObject`.
9. Select the **Output** checkbox.
10. Save the ruleset and try it out.

Done. You're ready now to call your ruleset via its API from any software you like. Click **Docs > Examples** for a `fetch` snippet to call the ruleset from JavaScript.&#x20;

## What's next?

Follow our [How-to Guides](/v2.4/how-to-guides.md) to add more functionality.&#x20;


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.rulecube.com/v2.4/how-to-guides/creating-input-from-json-schema.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
