Fix #982: vector initialized with json:[] string instead of empty by facontidavide · Pull Request #1073 · BehaviorTree/BehaviorTree.CPP · GitHub
Skip to content

Fix #982: vector initialized with json:[] string instead of empty#1073

Merged
facontidavide merged 1 commit into
masterfrom
fix/issue-982
Feb 1, 2026
Merged

Fix #982: vector initialized with json:[] string instead of empty#1073
facontidavide merged 1 commit into
masterfrom
fix/issue-982

Conversation

@facontidavide

Copy link
Copy Markdown
Collaborator

Summary

  • Fix std::vectorstd::string ports being initialized with literal json:[] string instead of empty vector
  • Handle json: prefix correctly in convertFromString specializations for vector types

Test plan

  • New test: PortTest.DefaultEmptyVector_Issue982
  • All existing tests pass (298/298)

Closes #982

@coderabbitai

coderabbitai Bot commented Feb 1, 2026

Copy link
Copy Markdown

…ions

When a port of type std::vector<T> has a default empty value {} and no
input is specified in XML, toStr() converts the empty vector to "json:[]".
The explicit convertFromString specializations for vector types did not
handle the "json:" prefix (unlike the generic template), so this string
was split by ';' producing a vector with one literal "json:[]" element.

Fix: add "json:" prefix detection at the top of all four vector
convertFromString specializations (int, double, bool, string). When
detected, parse directly with nlohmann::json instead of splitting by ';'.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@facontidavide facontidavide merged commit 223b3ed into master Feb 1, 2026
12 checks passed
@facontidavide facontidavide deleted the fix/issue-982 branch February 1, 2026 17:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Vectors being initialized with json:[] string

1 participant