0

I am using Devextreme control for filter builder, in this example https://js.devexpress.com/Demos/WidgetsGallery/Demo/FilterBuilder/WithDataGrid/jQuery/Light/

we have filter like

var filter = [
    ["Product_Current_Inventory", "<>", 0],
    "or",
    [
        ["Product_Name", "contains", "HD"],
        "and",
        ["Product_Cost", "<", 200]
    ]
]

I wanted to covert this to JSON, considering it could be a big filters also into new format like

Click here to see the format

1
  • Conversion to JSON happens with JSON.stringify. What is the problem with that? Are you sure your question is about JSON? Or is it about a JavaScript object? Too many people seem to mix up the two concepts. Commented Jun 27, 2019 at 20:25

1 Answer 1

0

create an algorithm to restructure the data in a new object in the desired format, then just use JSON.stringify() to turn it into JSON.

var jsonString = JSON.stringify( filter );
Sign up to request clarification or add additional context in comments.

4 Comments

can you take a look into Image ? since i am unable to edit this post
@KrishnaKanhiyaSanghi yeah, you just restructure your data how you like, using code. I'm not sure where you are running into problems, or what your question is regarding that. have you made an attempt at restructuring the data, and had problems, or are you just hoping someone will write the converter code for you?
Yeah it's a data conversion issue from one format to another, it's a recursion so i am stuck, i need help how to achieve this. However i am translated from JSON to above format
@KrishnaKanhiyaSanghi since, in your above question, you are actually asking two questions. "how do i convert this object into JSON?", and, "How do I convert this object's structure, into this other object structure?", consider asking a new question, and add the code you have already tried to make this conversion, and describe in what way your conversions results differ from what you expected after running the conversion code.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.