Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
137 changes: 77 additions & 60 deletions .github/lang/es-ES/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ Biblioteca PHP para la gestión de archivos JSON.

- [Requisitos](#requisitos)
- [Instalación](#instalación)
- [Métodos disponibles](#métodos-disponibles)
- [Cómo empezar](#cómo-empezar)
- [Clases disponibles](#clases-disponibles)
- [Clase Json](#clase-json)
- [Excepciones usadas](#excepciones-usadas)
- [Uso](#uso)
- [Tests](#tests)
- [Tareas pendientes](#tareas-pendientes)
Expand Down Expand Up @@ -56,84 +57,68 @@ También puedes **clonar el repositorio** completo con Git:
git clone https://github.com/josantonius/php-json.git
```

## Métodos disponibles
## Clases disponibles

Métodos disponibles en esta biblioteca:

### Obtener el contenido del archivo JSON
### Clase Json

```php
$json->get(): array
use Josantonius\Json\Json;
```

**@throws** `CreateDirectoryException` si no se puede crear el directorio.

**@throws** `CreateFileException` si no se puede crear el archivo.
Obtener el contenido del archivo JSON:

**@throws** `JsonErrorException` si hay un error al analizar un archivo JSON.
```php
/**
* @throws CreateDirectoryException if there is an error when creating a directory.
* @throws CreateFileException if there is an error when creating a file.
* @throws JsonErrorException if there is an error when parsing a JSON file.
*/
$json->get(): array
```

### Establecer el contenido del archivo JSON
Establecer el contenido del archivo JSON:

```php
/**
* @throws CreateFileException if there is an error when creating a file.
* @throws JsonErrorException if there is an error when parsing a JSON file.
* @throws UnavailableMethodException if the method is not available.
*/
$json->set(array|object $content): void
```

**@throws** `CreateFileException` si no se puede crear el archivo.

**@throws** `JsonErrorException` si hay un error al analizar un archivo JSON.

**@throws** `UnavailableMethodException` si el método no está disponible.

### Fusionar en el archivo JSON
Fusionar en el archivo JSON:

```php
/**
* @throws CreateFileException if there is an error when creating a file.
* @throws GetFileException if there is an error when getting a file.
* @throws JsonErrorException if there is an error when parsing a JSON file.
* @throws UnavailableMethodException if the method is not available.
*/
$json->merge(array|object $content): array
```

**@throws** `CreateFileException` si no se puede crear el archivo.

**@throws** `GetFileException` si no se puede obtener el archivo.

**@throws** `JsonErrorException` si hay un error al analizar un archivo JSON.

**@throws** `UnavailableMethodException` si el método no está disponible.

### Incluir en el archivo JSON
Incluir en el archivo JSON:

```php
/**
* @throws CreateFileException if there is an error when creating a file.
* @throws GetFileException if there is an error when getting a file.
* @throws JsonErrorException if there is an error when parsing a JSON file.
* @throws UnavailableMethodException if the method is not available.
*/
$json->push(array|object $content): array
```

**@throws** `CreateFileException` si no se puede crear el archivo.

**@throws** `GetFileException` si no se puede obtener el archivo.

**@throws** `JsonErrorException` si hay un error al analizar un archivo JSON.

**@throws** `UnavailableMethodException` si el método no está disponible.

## Cómo empezar

Para utilizar esta biblioteca con **Composer**:
## Excepciones utilizadas

```php
require __DIR__ . '/vendor/autoload.php';

use josantonius\Json\Json;
```

```php
$json = new Json('path/to/file.json');

# Si el archivo no existe, se creará.
```

O

```php
$json = new Json('https://site.com/file.json');

# Cuando el archivo JSON se obtiene desde una URL, sólo estará disponible el método "get".
use Josantonius\Json\Exceptions\CreateDirectoryException;
use Josantonius\Json\Exceptions\CreateFileException;
use Josantonius\Json\Exceptions\GetFileException;
use Josantonius\Json\Exceptions\JsonErrorException;
use Josantonius\Json\Exceptions\UnavailableMethodException;
```

## Uso
Expand All @@ -142,26 +127,38 @@ Ejemplo de uso para esta biblioteca:

### Obtener el contenido del archivo

**`file.json`**

```json
{
"foo": "bar"
}
```

```php
$json->get();
```
**`index.php`**

```php
['foo' => 'bar']
use Josantonius\Json\Json;

$json = new Json('file.json');

$json->get(); // ['foo' => 'bar']
```

### Establecer el contenido del archivo

**`index.php`**

```php
use Josantonius\Json\Json;

$json = new Json('file.json');

$json->set(['foo' => 'bar']);
```

**`file.json`**

```json
{
"foo": "bar"
Expand All @@ -170,16 +167,26 @@ $json->set(['foo' => 'bar']);

### Fusionar en el archivo

**`file.json`**

```json
{
"foo": "bar"
}
```

**`index.php`**

```php
use Josantonius\Json\Json;

$json = new Json('file.json');

$json->merge(['bar' => 'foo']);
```

**`file.json`**

```json
{
"foo": "bar",
Expand All @@ -189,6 +196,8 @@ $json->merge(['bar' => 'foo']);

### Incluir en el archivo

**`file.json`**

```json
[
{
Expand All @@ -197,10 +206,18 @@ $json->merge(['bar' => 'foo']);
]
```

**`index.php`**

```php
use Josantonius\Json\Json;

$json = new Json('file.json');

$json->push(['name' => 'bar']);
```

**`file.json`**

```json
[
{
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# CHANGELOG

## [v2.0.5](https://github.com/josantonius/php-json/releases/tag/v2.0.5) (2022-08-11)

* The exceptions directory was renamed from `exception` to `exceptions`.

* Improved documentation.

* Improved doc comments in `Josantonius\Json\Json`.

## [v2.0.4](https://github.com/josantonius/php-json/releases/tag/v2.0.4) (2022-07-13)

* Fix exceptions comment.
Expand Down
Loading