1

I have a complicated example of converting a Javascript Array to a JSON String.

Let's say I have two type of objects. The first type is called a Property, it has the fields: id, uri, label and values[] where values is an array of the second type of object.

The second type of object, called a Value has the fields: id, uri, label.

If I had a simple Array I believe I would do: var arrayAsJSON = myarray.stringify(); Would this work in this case. I have tried it and it comes back as undefined, but perhaps I am doing some else wrong.

1

1 Answer 1

2

In common you can use JSON.stringify(array), but not all browsers have this method implemented. However if you use some JS framework stringify is probably implemented there for old browsers.

Sign up to request clarification or add additional context in comments.

2 Comments

I feel pretty safe in admitting that's one of my stupidest mistakes .... thanks though :)
Don't blame yourself. Sometimes it's better to ask then spent the whole day in unsuccessful attempts.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.