JsonGetter

This package is a useful Flutter tool to extract values from JSON.

Features

  • Easily extract values from JSON structures.
  • Support for multiple filters to refine data extraction.

Getting started

To use this package, ensure you have Flutter installed and add the package to your pubspec.yaml.

  1. Add the package to your pubspec.yaml file:
dependencies:
  json_getter: ^0.0.3
  1. Import the package in your Dart file:
import 'package:json_getter/json_getter.dart';

Usage

With JSON String

const jsonString = '{"key1": "value1", "key2": "value2"}';
const filtersString = '{"filters":[{"selectorType":"getValueByKey","filterBy":null,"key":"key1","operator":null,"value":null}]}';
final filters = FiltersMapper.fromJson(filtersString);

final result = JsonGetter.get(filters: filters, json: jsonString);
print(result); // Output: value1

With JSON Map

const json = {'key1': 'value1', 'key2': 'value2'};
final filters = Filters(
  filters: [
    const Filter(
      selectorType: SelectorType.getValueByKey,
      key: 'key1',
    ),
  ],
);

final result = JsonGetter.get(filters: filters, json: json);
print(result); // Output: value1

Demo

👉 Json Getter Builder

image info

Additional information

For more information, visit the GitHub repository.

License

MIT License

Libraries

json_getter