{"id":15047509,"url":"https://github.com/danylevych/json","last_synced_at":"2026-01-02T00:09:41.569Z","repository":{"id":187210544,"uuid":"665582966","full_name":"danylevych/Json","owner":"danylevych","description":"The repository has classes that represet json types.","archived":false,"fork":false,"pushed_at":"2023-08-21T16:18:28.000Z","size":10027,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-13T20:21:26.226Z","etag":null,"topics":["cpp","cpp14","json","json-parsing","json-serialization"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/danylevych.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-07-12T14:20:38.000Z","updated_at":"2023-12-13T12:45:19.000Z","dependencies_parsed_at":null,"dependency_job_id":"45f0ea6b-e378-4755-8c18-1d17992875ef","html_url":"https://github.com/danylevych/Json","commit_stats":null,"previous_names":["danylevych/json"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danylevych%2FJson","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danylevych%2FJson/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danylevych%2FJson/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danylevych%2FJson/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danylevych","download_url":"https://codeload.github.com/danylevych/Json/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243475330,"owners_count":20296714,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cpp","cpp14","json","json-parsing","json-serialization"],"created_at":"2024-09-24T20:59:22.611Z","updated_at":"2026-01-02T00:09:41.541Z","avatar_url":"https://github.com/danylevych.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# **GUIDE**\n  - [How to include?](https://github.com/danylevych/Json/edit/master/README.md#how-to-include)\n    - [As other project](https://github.com/danylevych/Json#as-other-project)\n    - [As static lib](https://github.com/danylevych/Json#as-static-lib)\n  - [Data types](https://github.com/danylevych/Json#data-types)\n    - [Int](https://github.com/danylevych/Json#int)\n    - [Float](https://github.com/danylevych/Json#float)\n    - [Null](https://github.com/danylevych/Json#null)\n    - [Boolean](https://github.com/danylevych/Json#boolean)\n    - [String](https://github.com/danylevych/Json#string)\n    - [Array]()\n    - [Object]()\n\n\n\n# **How to include?**\n  Firstly, you need to download files from this repository.\n  You can do this by two ways.\u003cbr\u003e \n  ### First:\n  - Copy the url.\u003cbr\u003e\n    ![](/assets/includeImg/urlClone.png)\n    \n  - Open folder, that you need, and do the next.\u003cbr\u003e\u003cbr\u003e\n    ![](/assets/includeImg/openCMD.png)\n    \n  - When the comand line opened, enter the next text.\n    ```\n    git clone https://github.com/danylevych/Json.git\n    ```\n    ![](/assets/includeImg/enterCloneText.png)\n\n  ### Second:\n  - Download ZIP, and unpacked it.\u003cbr\u003e\u003cbr\u003e\n    ![](/assets/includeImg/downloadZIP.png)\n\n\n\n\n  ## **As other project**\n  - After your downloading, go to the folder where Json repository is storing and copy only `Json` folder from there (it's more that enough). Than paste its in your project.\u003cbr\u003e\u003cbr\u003e\n    ![](/assets/includeImg/pastingJson.png)\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\n\n  - Then go to Visual Studio (or program that you use), and add the Json project.\u003cbr\u003e\u003cbr\u003e\n    ![](/assets/includeImg/addJsonToVS1.png)\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\n    \n  - Than you need to add reference to Json project.\u003cbr\u003e\u003cbr\u003e\n    ![](/assets/includeImg/addJsonToVS2.png)\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\n    \n  - Now you can use `Json` as you need.\u003cbr\u003e\u003cbr\u003e\n     ![](/assets/includeImg/addJsonToVS3.png)\n\n\n\n\n  ## **As static lib**\n  - First, that you need it is copy `include` and `lib` folders in directory where your project is.\u003cbr\u003e\u003cbr\u003e\n    ![](/assets/includeImg/addJsonToVS4.png)\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\n    \n  - Open Visual Studio. Go to `Properties`, than `C/C++ -\u003e Genaral -\u003e Additional Include Directories`, and add the path to `include` folder for the option.\u003cbr\u003e\u003cbr\u003e\n    ![](/assets/includeImg/addJsonToVS5.png)\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\n    \n  - Next step - in `Properties` go to `Linker -\u003e General -\u003e Additional Library Directories`. Here you need to add the path to `lib` folder.\u003cbr\u003e\u003cbr\u003e\n    ![](/assets/includeImg/addJsonToVS6.png)\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\n    \n  - And last that you need is in `Linker` part go to `Input -\u003e Additional Dependencies`, and add the `JsonDebug.lib` and `JsonRelease.lib` at the option.\u003cbr\u003e\n    \u003e [!IMPORTANT]\n    \u003e For Release configuration add only `JsonRelease.lib`, and for Debug, as you can guess, it's `JsonDebug.lib`.\n    \u003cbr\u003e\n\n    - Switch the configuration to `Debug` and add the `JsonDebug.lib`.\u003cbr\u003e\u003cbr\u003e\n      ![](/assets/includeImg/addJsonToVS7.png)\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\n    - Switch the configuration to `Release` and add the `JsonRelease.lib`.\u003cbr\u003e\u003cbr\u003e\n      ![](/assets/includeImg/addJsonToVS8.png)\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\n    \n    - Now you can use it as you need.\u003cbr\u003e\u003cbr\u003e\n      ![](/assets/includeImg/addJsonToVS9.png)\n  \n\n\n# **Data types**\n  **Files with json extention can store the next data types:**\n  - Int\n  - Float\n  - Null\n  - Boolean\n  - String\n  - Array\n  - Object\n\n  \u003cbr\u003eSo, dicided to create each of this class for the comfortable work.\u003cbr\u003e\n  \n  **First that we need, it to see the hierarchy for them.**\u003cbr\u003e\n  \n\tCore::Types::BaseType ---|\n\t\t\t\t |----\u003e Core::Types::Int\n\t                         |----\u003e Core::Types::Float\n\t                         |----\u003e Core::Types::Null\n\t                         |----\u003e Core::Types::Boolean\n\t                         |----\u003e Core::Types::String\n\t                         |----\u003e Core::Types::Array\n\t                         |----\u003e Core::Types::Object\n\n \n  \u003cbr\u003eAs you can see each of them is a daughter class of the `Core::Types::BaseType`.\u003cbr\u003e\u003cbr\u003e\n\n\n**What is Core::Types::BaseType?**\u003cbr\u003e\u003cbr\u003e\n\n  The `Core::Types::BaseType` is a parent class. For it we can do somenthing like dynamic typization(if we can named it like that) for our project.\n  It has some virtual methods, such as `GetType()` and `Destructor`. It also has a protected field - `type`, which store the type of the current instance. In the below section you can see how `Core::Types::BaseType` look like.\n\n   ```cpp\n\tnamespace Core\n\t{\n\t\tnamespace Types\n\t\t{\n\t\t\tclass BaseType\n\t\t\t{\n\t\t\tprotected:\n\t\t\t\tJsonTypes type;\n\t\n\t\t\tpublic:\n\t\t\t\tBaseType(JsonTypes\u0026\u0026 type);\n\t\t\t\tBaseType(const JsonTypes\u0026 type);\n\t\t\t\n\t\t\tpublic:\n\t\t\t\tbool IsObject() const;\n\t\t\t\tbool IsArray() const;\n\t\t\t\tbool IsString() const;\n\t\t\t\tbool IsInt() const;\n\t\t\t\tbool IsFloat() const;\n\t\t\t\tbool IsBoolean() const;\n\t\t\t\tbool IsNull() const;\n\t\n\t\t\tpublic:\n\t\t\t\ttemplate\u003ctypename T\u003e\n\t\t\t\tT\u0026 Get() { return *dynamic_cast\u003cT*\u003e(this); }\n\t\n\t\t\tpublic:\n\t\t\t\tvirtual JsonTypes GetType() const = 0;\n\t\t\t\tvirtual ~BaseType() = default;\n\t\t\t\n\t\t\t};\n\t\t}\n\t}\n   ```\n\n  \u003cbr\u003e`Core::Types::BaseType` also has the template method `Get\u003cT\u003e()`, that can parse instance to data type that you send its. It use for the down casting, and it will be show later.\n  \n  \u003cbr\u003eNow is the time to talk about `type` field. As you can see, this field has a `Core::JsonTypes`. This is enumeration, which store names of all those types, that we were talking before.\n   ```cpp\n\tnamespace Core\n\t{\n\t\tenum class JsonTypes\n\t\t{\n\t\t\tObject = 1,\n\t\t\tArray,\n\t\t\tString,\n\t\t\tInt,\n\t\t\tFloat,\n\t\t\tBoolean,\n\t\t\tNull\n\t\t};\n\t}\n   ```\n  \u003cbr\u003e\n\n  \u003e [!IMPORTANT]\n  \u003e Each of the classes has one mhetod, that only return the reference, or const reference, to the value, that the class is storing - `SotoreValueType\u0026 Value()` or `const SotoreValueType\u0026 Value() const`.\n\n  \u003cbr\u003eAlso we are going to talk about check's type methods. It is the `Core::Types::BaseType::IsSomeType()`, this mhetod return true if current instance has the same `type` like one that is in `SomeType` (for example: if we call the `Core::Types::BaseType::IsInt()`, it will return `true` if current instance store the `Core::Types::Int`, and `false` in oposite situation).\n\n  ## **Int**\n\n  The json's `int` or `number`, call it as you want, has represented as `Core::Types::Int` class. That is a wrapper for `int` type. So, you can yse it as default `int` variable.\n  \n  ### Mhetods\n\n  | Mhetod's name | Description |\n  | ------------- | ----------- |\n  | `Int()` | Default cunstructer, that initialize `variavle` defult value - `0`. |\n  | `Int(int value)` | Constructer, that takes one parameters `value`, that will be storing. |\n  | `Int(const Int\u0026 ohter)` | Copy constructer. |\n  | `Int(Int\u0026\u0026 ohter) noexcept` | Move constructer. |\n  | `Int\u0026 operator=(const Int\u0026 other)` | Assigment copy operator. |\n  | `Int\u0026 operator=(Int\u0026\u0026 other) noexcept` | Assigment move opertor. |\n  |\u003cbr\u003e|\u003cbr\u003e|\n  | `operator int\u0026()` | Type cast operator, that returns the reference to the storing value. |\n  | `operator const int\u0026() const` | Type cast operator, that returns the const reference to the storing value. |\n  | `operator int() const`| Type cast operator to `int` type |\n  | `operator Int() const`| Type cast operator to `Core::Types::Int` type. |\n  |\u003cbr\u003e|\u003cbr\u003e|\n  | `virtual JsonTypes GetType() const` | Overloaded `Core::Types::BaseType`'s method, that returns a type of this class. (You can say, that is unuseless, but we will have seen it late :D) |\n  |\u003cbr\u003e|\u003cbr\u003e|\n  | `int\u0026 Value()` | Returns the reference to value which is inside in class. |\n  | `const int\u0026 Value() const` | Returns the const reference to value which is inside in class. |\n\n  \n  \u003cbr\u003eAs the `Core::Types::Int` is a doughter calss from the `Core::Types::BaseTypes`, it has all methods, that `Core::Types::BaseTypes` has.\n  \u003cbr\u003e\n\n  ## **Float**\n\n  The `Core::Types::Float` is a class, that can store a fractional number. It's only a wrapper under `double` type.\n\n  ### Mhetods\n\n  | Mhetod's name | Description |\n  | ------------- | ----------- |\n  | `Float()` | Default cunstructer, that initialize `variavle` defult value - `0.0`. |\n  | `Float(double value)` | Constructer, that takes one parameters `value`, that will be storing. |\n  | `Float(const Float\u0026 ohter)` | Copy constructer. |\n  | `Float(Float\u0026\u0026 ohter) noexcept` | Move constructer. |\n  | `Float\u0026 operator=(const Float\u0026 other)` | Assigment copy operator. |\n  | `Float\u0026 operator=(Float\u0026\u0026 other) noexcept` | Assigment move opertor. |\n  |\u003cbr\u003e|\u003cbr\u003e|\n  | `operator double\u0026()` | Type cast operator, that returns the reference to the storing value. |\n  | `operator const double\u0026() const` | Type cast operator, that returns the const reference to the storing value. |\n  | `operator double() const`| Type cast operator to `double` type |\n  | `operator Float() const`| Type cast operator to `Core::Types::Float` type. |\n  |\u003cbr\u003e|\u003cbr\u003e|\n  | `virtual JsonTypes GetType() const` | Overloaded `Core::Types::BaseType`'s method, that returns a type of this class. (You can say, that is unuseless, but we will have seen it late :D) |\n  |\u003cbr\u003e|\u003cbr\u003e|\n  | `double\u0026 Value()` | Returns the reference to value which is inside in class. |\n  | `const double\u0026 Value() const` | Returns the const reference to value which is inside in class. |\n\n  \u003cbr\u003eAs the `Core::Types::Float` is a doughter calss from the `Core::Types::BaseTypes`, it has all methods, that `Core::Types::BaseTypes` has.\n  \u003cbr\u003e\n\n  ## **Null**\n\n  Json's files have the `null` type, so, the `Core::Types::Null` represent it in my class.\n\n  ### Mhetods\n\n  | Mhetod's name | Description |\n  | ------------- | ----------- |\n  | `Null()` | Default cunstructer, that initialize `variavle` defult value - `nullptr`. |\n  |\u003cbr\u003e|\u003cbr\u003e|\n  | `operator std::string\u0026() const` | Type cast operator, that returns the instance of `std::string`, which look like `\"null\"`. |\n  | `operator bool() const` | Type cast operator, that always returns `false`. |\n  |\u003cbr\u003e|\u003cbr\u003e|\n  | `virtual JsonTypes GetType() const` | Overloaded `Core::Types::BaseType`'s method, that returns a type of this class. (You can say, that is unuseless, but we will have seen it late :D) |\n  |\u003cbr\u003e|\u003cbr\u003e|\n  | `const std::nullptr_t\u0026 Value() const` | Returns the const reference to value which is inside in class. |\n  |\u003cbr\u003e|\u003cbr\u003e|\n  | `std::ostream\u0026 operator\u003c\u003c(std::ostream\u0026 out, const Null\u0026 null)` | The overloaded out operator. |\n\n  \u003cbr\u003eAs the `Core::Types::Null` is a doughter calss from the `Core::Types::BaseTypes`, it has all methods, that `Core::Types::BaseTypes` has.\n  \u003cbr\u003e\n\n  ## **Boolean**\n  The `Core::Types::Boolean` represented `bool` type.\n\n  ### Mhetods\n\n  | Mhetod's name | Description |\n  | ------------- | ----------- |\n  | `Boolean()` | Default cunstructer, that initialize `variavle` defult value - `false`. |\n  | `Boolean(bool value)` | Constructer, that takes one parameters `value`, that will be storing. |\n  | `Boolean(const Boolean\u0026 ohter)` | Copy constructer. |\n  | `Boolean(Boolean\u0026\u0026 ohter) noexcept` | Move constructer. |\n  | `Boolean\u0026 operator=(const Boolean\u0026 other)` | Assigment copy operator. |\n  | `Boolean\u0026 operator=(Boolean\u0026\u0026 other) noexcept` | Assigment move opertor. |\n  |\u003cbr\u003e|\u003cbr\u003e|\n  | `operator bool\u0026()` | Type cast operator to `bool` reference. |\n  | `operator const bool\u0026() const` | Type cast operator to `bool` const reference. |\n  | `operator bool() const` | Type cast operator, that return current state of `value`, it's can be `true` or `false`. |\n  | `operator std::string() const` | Type cast operator, which return `std::string` instance, that look like `\"true\"` or `\"false\"` - it's depending of state `value` inside the current instance. |\n  |\u003cbr\u003e|\u003cbr\u003e|\n  | `virtual JsonTypes GetType() const` | Overloaded `Core::Types::BaseType`'s method, that returns a type of this class. (You can say, that is unuseless, but we will have seen it late :D) |\n  |\u003cbr\u003e|\u003cbr\u003e|\n  | `bool\u0026 Value()` | Returns the reference to value which is inside in class. |\n  | `const bool\u0026 Value() const` | Returns the const reference to value which is inside in class. |\n  |\u003cbr\u003e|\u003cbr\u003e|\n  | `std::ostream\u0026 operator\u003c\u003c(std::ostream\u0026 out, const Boolean\u0026 boolean)` | The overloaded out operator. |\n\n  \u003cbr\u003eAs the `Core::Types::Null` is a doughter calss from the `Core::Types::BaseTypes`, it has all methods, that `Core::Types::BaseTypes` has.\n  \u003cbr\u003e\n\n  ## **String**\n\n  So, now we are going to talk about `Core::Types::String`. This class is reptresenting json's `string`. The `Core::Types::String` is a wrapper under the `std::wstring`. \n  *Why is `std::wstring`, and not `std::string`?* \n  Because, the json can works with `utf 8` format of coding, so, I think, thet it was optimal to use `std::wstring`.\n\n  ### Mhetods\n\n  | Mhetod's name | Description |\n  | ------------- | ----------- |\n  | `String()` | Default cunstructer, that initialize `variavle` defult value - `false`. |\n  | `String(const char* value)` | Constructer, that gets `const char*` values. |\n  | `String(std::string\u0026\u0026 value)` | Constructer, that gets r-value instances of `std::string`. |\n  | `String(const std::string\u0026 value)` | Constructer, that gers l-value instance of `std::string`. |\n  | `String(std::wstring\u0026\u0026 value)` | Constructer, that gets r-value instances of `std::wstring`. |\n  | `String(const std::wstring\u0026 value)` | Constructer, that gers l-value instance of `std::wstring`. |\n  | `String(const String\u0026 other)`| Copy constructer. |\n  | `String(String\u0026\u0026 other)`| Move constructer. |\n  | `String\u0026 operator=(const String\u0026 other)` | Assigment copy operator. |\n  | `String\u0026 operator=(String\u0026\u0026 other) noexcept` | Assigment move opertor. |\n  |\u003cbr\u003e|\u003cbr\u003e|\n  | `operator std::string() const` | Overloaded type cast operator to `std::string`. |\n  | `operator std::wstring\u0026()` | Overloaded type cast operator, which returns the reference to the value, that stored in the current instance of `Core::Types::String`. |\n  | `operator const std::wstring\u0026() const` | Overloaded type cast operator, which returns the const reference to the value, that stored in the current instance of `Core::Types::String`. |\n  |\u003cbr\u003e|\u003cbr\u003e|\n  | `virtual JsonTypes GetType() const` | Overloaded `Core::Types::BaseType`'s method, that returns a type of this class. (You can say, that is unuseless, but we will have seen it late :D) |\n  |\u003cbr\u003e|\u003cbr\u003e|\n  | `std::wstring\u0026 Value()` | Returns the reference to value which is inside in class. |\n  | `const std::wstring\u0026 Value() const` | Returns the const reference to value which is inside in class. |\n  |\u003cbr\u003e|\u003cbr\u003e|\n  | `bool operator\u003c(const String\u0026 other) const` | Overloaded less operator. |\n  | `bool operator\u003e(const String\u0026 other) const` | Overloaded greater operator. |\n  | `bool operator!=(const String\u0026 other) const` | Overloaded equal operator. |\n  | `bool operator==(const String\u0026 other) const` | Overloaded not equal operator. |\n  |\u003cbr\u003e|\u003cbr\u003e|\n  | `std::ostream\u0026 operator\u003c\u003c(std::ostream\u0026 out, const String\u0026 string)` | The overloaded out operator. Its returs the `std::ostream\u0026` that has a string like in json - `\"some text\"`. |\n\n  \u003cbr\u003eAs the `Core::Types::String` is a doughter calss from the `Core::Types::BaseTypes`, it has all methods, that `Core::Types::BaseTypes` has.\n  \u003cbr\u003e\n\n  ## **Array**\n\n  Now, we will talking, about something interesting, this is a `Core::Types::Array`.\n  \n  `Core::Types::Array` is a class that, can store a set of each types, that is here. And if i say 'all' it's mean all, including itself, and `Core::Types::Object`(this is the next, and finaly data type that we need to talk, but it will be later).\n\n  As I said it can store all data types, and it can do this because of it is a wrapper under `std::vector\u003cstd::unique_ptr\u003cCore::Types::BaseType\u003e\u003e`. It saves the poiters into all values, so we can do down cast ad get the type, which we need.\n\n  First that I need to explain is all aliases.\n  - `BaseTypePtrT` - is the aliase of `Core::Types::BaseType*`\n  - `BaseSmartPtrT` - is the aliase of `std::unique_ptr\u003cCore::Types::BaseType\u003e`\n\n  Simply?\n\n  I can talk to you a lot of story of this class, but let's go to view methods that are in its, and after this I will show some exanples.\n\n  Sooooooo, let's go.\n\n  ### Mhetods\n  \n  | Mhetod's name | Description |\n  | ------------- | ----------- |\n  | `Array()` | Default constructer. |\n  | `Array(const std::initializer_list\u003cBaseTypePtrT\u003e\u0026 list)` | Constructer, that gets a list of raw pointers as parameters ([Example]()), i guss that it will be the most usefull, and common method. |\n  | `Array(Array\u0026\u0026 other) noexcept` | Move constructer. |\n  | `Array\u0026 operator=(Array\u0026\u0026 other) noexcept` | Assigment move operator. |\n  | `Array\u0026 operator=(const std::initializer_list\u003cBaseTypePtrT\u003e\u0026 list)` | Assigment operator, that gets a list of raw pointers. |\n  \n  \u003e[!IMPORTANT]\n  \u003e The `Core::Types::Array` doesn't have a copy constructer and copy assigment operator, oh no, these methods have been removed, because we are working with the pointers. \n  \u003e\n  \u003e Yep, you can ask, \"we can copy values of each element not an address, so why do not you do it?\". \n  \u003e\n  \u003e Simply, I did not to do it because I like procrastination. Don't worry, maybe I do it as fast as I can.\n  \n  | Mhetod's name | Description |\n  | ------------- | ----------- |\n  | `std::vector\u003cBaseSmartPtrT\u003e\u0026 Value()` | This method returns the reference to inner array. |\n  | `const std::vector\u003cBaseSmartPtrT\u003e\u0026 Value() const` | This method returns the `const` reference to inner array. |\n  | `operator std::string() const` | Type cast operator, which returns the array as `std::string`.  |\n  |\u003cbr\u003e|\u003cbr\u003e|\n  | `ReturnedDataJson operator[](size_t index)` | Overloaded index operator, its returns `ReturnedDataJson` type, we are seeing it later (you can wath some info about this class here [\u003cu\u003e`ReturnedDataJson`\u003c/u\u003e]()). |\n  | `const ReturnedDataJson operator[](size_t index) const` | Overloaded index operator, its returns `ReturnedDataJson` type, we are seeing it later (you can wath some info about this class here [\u003cu\u003e`ReturnedDataJson`\u003c/u\u003e]()). | \n  |\u003cbr\u003e|\u003cbr\u003e|\n  | `virtual JsonTypes GetType() const` | Overloaded `Core::Types::BaseType`'s method, that returns a type of this class. |\n  |\u003cbr\u003e|\u003cbr\u003e|\n  | `void PushBack(BaseTypePtrT ptr)` | This method provide to us ability to insert value (\u003cu\u003e**raw pointer**\u003c/u\u003e that has alocated on the heap(dymamic memory)) into `Core::Types::Array`, to back of course. |\n  | `void PushBack(BaseSmartPtrT\u0026\u0026 ptr)` | This method provide to us ability to insert value (\u003cu\u003e**smart pointer**\u003c/u\u003e that has alocated on the heap(dymamic memory)) into `Core::Types::Array`, to back of course. |\n  | Add the method for receving l-value BaseSmartPtrT | |\n  | `size_t Size() const` | Returns size of array. |\n  | `void Clear()` | Deletes all elements in array. |\n  | `bool Empty() const` | Checks if array is empty, and if it realy empty it returns `true`, oposite - `false` |\n  | `const std::vector\u003cBaseSmartPtrT\u003e\u0026 Data() const` | Returns the inner array, most correct `const` reference to its. |\n  | `ReturnedDataJson Front()` | Returns the object of `ReturnedDataJson` (now think about `ReturnedDataJson` as reference to some element) to first element in `Core::Types::Array`. |\n  | `const ReturnedDataJson Front() const` | Returns the object of `const ReturnedDataJson` (now think about `ReturnedDataJson` as reference to some element) to last element in `Core::Types::Array`. |\n  | `ReturnedDataJson Back()` | Returns the object of `ReturnedDataJson` (now think about `ReturnedDataJson` as reference to some element) to first element in `Core::Types::Array`. |\n  | `const ReturnedDataJson Back() const` | Returns the object of `const ReturnedDataJson` (now think about `ReturnedDataJson` as reference to some element) to last element in `Core::Types::Array`. |\n  | `void PopBack()` | Deletes last element in `Core::Types::Array`. |\n  | `void Swap(Array\u0026 other)` | Swaps two instances of `Core::Types::Array`. |\n  | `iterator Insert(const_iterator where, BaseSmartPtrT\u0026\u0026 val)` | Inserts value into array by hint, and returns the `iterator` of this value in array. |\n  | `template \u003ctypename ...Arg\u003e iterator Emplace(const_iterator where, Arg\u0026\u0026... arg)` | Inserts value into array by hint, and returns the `iterator` of this value in array. Difference between this method and previous one is that this builds the value at the time of inserting, and `Insert` gets the value that has been built previosly. |\n  | `iterator Erase(const_iterator where)` | Deletes element into array by `iterator`. |\n  | `iterator Erase(const_iterator first, const_iterator last)` | Deletes the range of elements from `first` to `last`. |\n\n  #### **Iterators**\n  The `Core::Types::Array` has methods, which return or get the iterator's data type - `iterator`, `const_iterator`, `reverce_iterator` or `const_reverse_itertor`. So, we are going to talk for these iterator's classes.\n\n  \u003cbr\u003e\n\n  \u003e[!NOTE]\n  \u003eIf you have or had some experience of working with the iterators in STL, it is the same, so it's must be easy to understand.\n  \u003e\u003cbr\u003e\n  \u003e But if you haven't experience in this field don't worry, I will try to explane what are the iterators, and how we can it 'eat'.\n\n  \u003cbr\u003e \n  \n  ##### **First step into iterators**\n  Iterator - is the object that provide to us ability of bypass each element in colection.\n  \n  So, now we have known definition of iterator notion. But for you, as i thing this is not enough, because definitions of all notion is so boring. Therefore we are going to study its in some examples.\n\n  But first some pictures for deep understanding what is.\n  \n  So, image that we have an array(it can be some another data type like hash table, binary tree, bidirectional list, forward list ect.) like in the image below.\u003cbr\u003e\n    ![](/assets/iteratorExamples/1.png)\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\n  \n  **How we can walked for each element?**\n  \n  If you know operations that we can do with pointer, you probably said: \"We can get all elements by adding to name of the array(Hint if you forget. Array's name is the pointer to first element of range.) some value.\".\n\n  Yep, actually you can do it, but what will you do at the below situation.\u003cbr\u003e\n    ![](/assets/iteratorExamples/2.png)\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\n\n  Now, it will be difficult, because in this cause you need to create some method that gets index, which you need probably `GetElement()`, or, of course, you can do overloading this operator `[]`. But this apporch we will have slow speed of code execution. \n\n  **Why?**\n  \n  Simply, image you wrote code like this for `List`:\n  ```cpp\n  // headers\n\n\n  class List\n  {\n  private:\n      struct Node\n      {\n          int data;\n          Node* next;\n      };\n\n  private:\n      Node* head;\n      size_t size;\n\n  public:\n      // ...\n      // some methods.\n      // ...\n\n      int GetElement(size_t index) \n      {\n          if (index \u003c 0 || index \u003e= size)\n          {\n              throw std::out_of_range(\"index: \" + std::to_string(index) + \" is out of the range\");\n          }\n          \n          Node* current = head;\n          for (size_t i = 0; i != index; i++)\n          {\n              current = head-\u003enext;\n          }\n\n          return current-\u003edata;\n      }\n  };\n\n\n  int main()\n  {\n      List list = { 3, 5, 10, 15, 45, 7, 8};\n\n      for (size_t i = 0; i \u003c list.Size(); i++)\n      {\n          std::cout \u003c\u003c list.GetElement(i) \u003c\u003c std::endl;\n      }\n\n\n      return 0;\n  }\n  ```\n  \n  In this instance we have a loop in `main` that calls `GetElement()` in each iteration, and that method has anoother loop. In the GIF below you can see how it work.\u003cbr\u003e\n  \n  ![](/assets/IteratorExamples/ListLoop.gif)\u003cbr\u003e\u003cbr\u003e\n\n  So, we have a loop, that has a loop, and as you can geuss, speed of this pice of code will be **O(n\u003csup\u003e2\u003c/sup\u003e)**. This speed will be too slow for big data set. \n\n  **How can we change speed of code execution?**\n\n  For this we can create iterators for our list. Image iterator as a pointer to some element in range. Each class, which is iterator, sould have overloaded `operator++` and `operator--`, those operators provide ability to bypass in the range by time **O(n)**.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanylevych%2Fjson","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanylevych%2Fjson","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanylevych%2Fjson/lists"}