JSON в PHP-класс
JSON и формат данных · Бесплатный онлайн-инструмент
Преобразование JSON в PHP-класс со свойствами.
<?php
class Root
{
public string $name;
public function getName(): string
{
return $this->name;
}
public function setName(string $name): void
{
$this->name = $name;
}
public int $age;
public function getAge(): int
{
return $this->age;
}
public function setAge(int $age): void
{
$this->age = $age;
}
public bool $active;
public function getActive(): bool
{
return $this->active;
}
public function setActive(bool $active): void
{
$this->active = $active;
}
public float $score;
public function getScore(): float
{
return $this->score;
}
public function setScore(float $score): void
{
$this->score = $score;
}
public Address $address;
public function getAddress(): Address
{
return $this->address;
}
public function setAddress(Address $address): void
{
$this->address = $address;
}
public array $skills;
public function getSkills(): array
{
return $this->skills;
}
public function setSkills(array $skills): void
{
$this->skills = $skills;
}
}
class Address
{
public string $city;
public function getCity(): string
{
return $this->city;
}
public function setCity(string $city): void
{
$this->city = $city;
}
public string $zip;
public function getZip(): string
{
return $this->zip;
}
public function setZip(string $zip): void
{
$this->zip = $zip;
}
}Типизированные свойства
int, float, string, bool, array — типизированные свойства PHP 7.4+.
Вложенные классы
Объекты становятся именованными классами, рекурсивно.
Геттеры и сеттеры
Аксессоры с типами возврата генерируются для каждого поля.
Как пользоваться: JSON в PHP-класс
- 1Paste your input data (JSON, CSV, XML, YAML, etc.) into the input field.
- 2The tool automatically processes and validates your data.
- 3Review the converted output in the result panel.
- 4Copy or download the converted result.
Возможности
- ✓100% бесплатно — без регистрации, подписки и рекламы
- ✓Работает полностью в браузере — данные не покидают ваше устройство
- ✓Быстро и легко — мгновенный результат
- ✓Кроссплатформенность — компьютеры, планшеты и смартфоны
Часто задаваемые вопросы
Can I convert large JSON files?
Yes, but performance depends on your browser. Files up to 10MB are generally handled well.
Do you validate the input?
Yes, most tools validate input and show error messages with line numbers for invalid data.
Can I download the converted result?
Yes, most conversion tools provide a download button for the output file.
Похожие инструменты
Форматирование JSON
Форматирование, валидация и минификация JSON.
JSON в CSV
Преобразование массива JSON в формат CSV.
CSV в JSON
Преобразование данных CSV в массив JSON.
JSON в XML
Преобразование объектов JSON в формат XML.
XML в JSON
Преобразование XML в JSON с помощью DOMParser.
JSON в YAML
Преобразование JSON в формат YAML.