question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

why this object is not parsed correctly? (help wanted!!!)

See original GitHub issue

Hi, i’m trying to stringify and parse this object but i’m keep getting the wrong result… every this newFiltes[0].filters[0/1].value.value should be array of strings, it’s always transforming this array to {0: 'string', 1: 'string'} no matter what i pass to arrayLimit… hope i’m not missing something here. thanks. https://codesandbox.io/s/musing-alex-l8i2h7?file=/src/App.js Screen Shot 2022-08-21 at 1 48 49

{
  newFilters: [
    {
      id: 0,
      filters: [
        {
          value: {
            value: [1660424400000, 1661115599999],
            operator:
              "eyJuYW1lIjoiX2FuZCIsInR5cGUiOiJtYXRjaCIsImxhYmVsIjoiRHVyaW5nIiwiY29tcG9uZW50cyI6WyJleUp1WVcxbElqb2lYMmQwWlNJc0lteGhZbVZzSWpvaVIzSmxZWFJsY2lCMGFHRnVJR1Z4ZFdGc0luMD0iLCJleUp1WVcxbElqb2lYMngwWlNJc0lteGhZbVZzSWpvaVRHVnpjeUIwYUdGdUlHVnhkV0ZzSW4wPSJdfQ=="
          },
          name: "date",
          type: "date",
          isDefault: true
        },
        {
          value: {
            value: ["60071434"],
            operator: "eyJuYW1lIjoiX2luIiwibGFiZWwiOiJNYXRjaCBhbnkifQ=="
          },
          name: "accounts",
          type: "accounts"
        }
      ],
      conjunction: "and"
    }
  ]
}

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
baaraakcommented, Aug 21, 2022

not relevant because I’m saving the data in a different structure now, so the new structure works fine. I assumed that probably I have a typo somewhere and it’s not a bug in qs. BTW, I’m trying to add the arrayFormat: indices, but it’s still not working…

const sting = stringify(filters, {arrayFormat: 'indices'});
const parsed = parse(sting, {arrayLimit: 100});
console.log(parsed);

still going to transform the value.value arrays into objects https://codesandbox.io/s/restless-meadow-3zbxi8?file=/src/App.js

0reactions
ljharbcommented, Aug 21, 2022

I see what you mean: https://codesandbox.io/s/bitter-cloud-1jc73n?file=/src/App.js it round trips to a string correctly, but not to the initial nested array. This is definitely worth fixing.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why is this JSON not being parsed correctly? - Stack Overflow
It's because there are line breaks in your strings. If you view the source of the JSON page, you can see them all....
Read more >
SyntaxError: JSON.parse: bad parsing - JavaScript | MDN
What went wrong? JSON. parse() parses a string as JSON. This string has to be valid JSON and will throw this error if...
Read more >
Solved: Flow - Parse JSON Dynamic Content not showing in O...
Flow is driving me crazy with this issue. I have a flow (which runs successfully) that includes a "Parse JSON" and "Send an...
Read more >
Error while parsing JSON Response in REST API Post call
When I invoke the same REST method through the UI, it is raising a parsing error.
Read more >
Parse nested JSON object? - Zapier Community
How can we access nested JSON object elements in a Zapier Webhook? I tried with javascript and json.parser and that's not work for...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found