Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • A ArduinoJson
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 24
    • Issues 24
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Benoît Blanchon
  • ArduinoJson
  • Merge requests
  • !695

Adjust nest level counting to make it algebraically coherent

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Administrator requested to merge github/fork/Adam5Wu/fix/coherent_nesting into issue693 Mar 09, 2018
  • Overview 1
  • Commits 2
  • Pipelines 0
  • Changes 3

Created by: Adam5Wu

I am proposing a small adjustment to the nest level counting so that it is more coherent:

  1. Simple values (boolean, string, number) are of nest level 0
  2. Each layer of object/array increase the nest level by 1

This resolves the nest level loophole when programatically generating nested structures: Before:

  • when inserting a simple value (nest level 0) to a flat array (nest level 0)
    • The result can be serialized and parsed back with nest limit of 0
    • Nest level: 0 + 0 = 0
  • But when inserting a flat object (nest level 0) to a flat array (nest level 0)
    • The result cannot be serialized and parsed back with nest limit of 0
    • Nest level: 0 + 0 = 1

After:

  • Inserting a single value (nest level 0) to a flat object (nest level 1):
    • The result can be serialized and parsed back with nest limit of 1
    • Nest level: 0 + 1 = 1
  • Inserting a flat object (nest level 1) to a flat array (nest level 1):
    • The result can be serialized and parsed back with nest limit of 2
    • Nest level: 1 + 1 = 2

As a (possibly good) side effect, this patch also makes the parseAnythingToUnsafe() method unnecessary.

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/Adam5Wu/fix/coherent_nesting