Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7185077
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T18:20:08+00:00 2026-05-28T18:20:08+00:00

I want to make an array with libJSON’s JSONNode . I’ve tried the following,

  • 0

I want to make an array with libJSON’s JSONNode. I’ve tried the following, but it doesn’t work:

JSONNode array;
JSONNode foo("word", "foo");
JSONNode bar("word", "bar");
array.push_back(foo);
array.push_back(bar);

This results in:

{ 
    "word": "foo", 
    "word": "bar"
}

What I want is:

[
    {"word": "foo"},
    {"word": "bar"}
]

It’s clear to me that I’m not specifying that I want an array. The thing is, I’ve searched the library and googled a bit, but I find no way to do this. Can anybody help me out with this?

(Sidenote: I wanted to add a “libjson” tag, but that doesn’t exist yet, it seems.)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T18:20:09+00:00Added an answer on May 28, 2026 at 6:20 pm

    You need to specify that you’re creating an array and complex nodes:

    JSONNode array(JSON_ARRAY);
    JSONNode foo(JSON_NODE);
    JSONNode bar(JSON_NODE);
    
    foo.push_back(JSONNode("word", "foo"));
    bar.push_back(JSONNode("word", "bar"));
    
    array.push_back(foo);
    array.push_back(bar);
    

    See the “Getting Started” documentation in libjson-VERSION.zip for some basic examples.

    Side note: I’ve personally found libjson to be annoying to work with, and the documentation is severely lacking. In my own projects, I use either JsonCpp or (more frequently) Jansson as my C/C++ JSON API. If you’re not locked in to libjson, you might give them a try.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to make an array of Unicode characters, but I don't know how
I want to make an array of size N in go, but I don't
Say I want to echo an array but I want to make the value
I have the following values: $attached_products = 1,4,3; I want to make an array
I want to make a dynamic array of foo, with the number of items
I want to make a 2D array dij(i and j are subscripts). I want
I want to make a variable length array in Javascript. Is this possible. A
i want to find values in array according to alphabate and want to make
I have an array, and I want to make a hash so I can
I want to combine 2 parts of the same array to make a complex

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.